这是一个查出全部的SQL语句
SELECT UserID,UserName,SUM(State)*100 AS State FROM vYD_VoteCategoryUserValues WHERE (isHot<>0) GROUP BY UserID,UserName ORDER BY State desc
我现在要查出state的值最高的,如果有并列最高的,我也要把并列的查出来,这个SQL语句怎么写啊!
SELECT A.UserID,A.UserName,A.State FROM (SELECT UserID,UserName,SUM(State)*100 AS State FROM vYD_VoteCategoryUserValues WHERE (isHot<>0) GROUP BY UserID,UserName) A
INNER JOIN (SELECT MAX(State) CState FROM (SELECT UserID,UserName,SUM(State)*100 AS State FROM vYD_VoteCategoryUserValues WHERE (isHot<>0) GROUP BY UserID,UserName ) B ) C
ON C.Cstate=A.State