【笔记】MySQL查询排名

select a.name, a.total_score,@rank:=@rank+1 as rank from (    
              select u.name,uti.total_score from user_total_integral uti left join tuser u on uti.user_id=u.id  WHERE u.status = 1 AND u.id <> '9001' and total_score>0 GROUP BY  uti.user_id  ORDER BY uti.total_score  DESC ,uti.user_id DESC
        ) a ,(select @rank:=0) b

posted @ 2016-12-09 22:17  我的bug  阅读(493)  评论(1编辑  收藏  举报