mysql中如何添加排序名
mysql中为排序添加排序名的方法
语法:
SELECT (@rownum:= @rownum+1) AS rank FROM (
SELECT * FROM (自己的表名)
) a,(SELECT @rownum:=0) b
使用方法:
SELECT a.userId,a.userName,a.sumInterval, a.tomatoNumber, @rownum := @rownum + 1 as rank
FROM (
SELECT
user_id AS userId,
user_name AS userName,
sum( tomato_time_interval ) AS sumInterval,
COUNT( user_id ) AS tomatoNumber
FROM
`tm_record_s`
WHERE
state = '1'
AND tomato_time_interval >= 1500
AND tomato_date = '2019-04-26'
GROUP BY
user_id
ORDER BY
COUNT( user_id ) DESC
) a, (SELECT @rownum :=0) b
声明:本站所有作品(图文、音视频)均由用户自行上传分享,或互联网相关知识整合,仅供网友学习交流,若您的权利被侵害,请联系 管理员 删除。
本文链接:http://news.ew35.com/