我有2张这样的桌子
[信息]
[得分]
我想在5月DESC class a:
def __init__(self,b,c):
self.b=b
self.c=c
def getstring(self):
print "Please enter input"
self.x=raw_input()
return x
def printstring(self):
y=self.x.upper()
return y
def sum(self):
c=self.c+self.b
return c
d=a(23,53)
d.getstring()
d.printstring()
结果应该看起来像这样。
答案 0 :(得分:0)
尝试在派生表中的两个表上进行JOIN,并在SUM上获得Score和该值的顺序
SELECT TOP 3 *
FROM(
SELECT
I.User_Id, I.[Name], I.Age, Score = SUM(S.Score)
FROM
Info I
INNER JOIN
Score S On S.User_Id = I.User_Id
WHERE MONTH(S.[DATE]) = 5 --May (however I suspect this might not be a DATE object)
GROUP BY
I.User_Id, I.[Name], I.Age
) X
ORDER BY X.Score DESC
答案 1 :(得分:0)
在这里,您可以使用join语句。
SELECT TOP(3) a.user_id, a.Name, a.Age, b.Score FROM Users a JOIN Score b On a.user_id=b.user_id Order By b.Score desc
答案 2 :(得分:0)
以下内容会有所帮助。
SELECT TOP 3 S.User_Id, SUM(S.Score) Score, U.Name, U.Age
FROM Info U
INNER JOIN Score S ON U.User_Id = S.User_Id
WHERE MONTH(S.Date) = 5 --Only May Month.
GROUP BY S.User_Id, U.Name, U.Age
ORDER BY 2 DESC