mysql 查询用户当前消费排名位置sql
:
SELECT b.* FROM
(
SELECT t.*, @rownum := @rownum + 1 AS rownum
FROM (SELECT @rownum := 0) r,
(SELECT to_uid,sum(account_price) score FROM video_order where state = 2 group by to_uid ORDER BY score DESC) AS t
) AS b WHERE b.to_uid = 100000002 limit 1;