Mysql中为排序添加排序名的方法语法:SELECT (@rownum:= @rownum+1) AS rank FROM (SELECT * FROM (自己的表名)) a,(SELECT @rownum:=0)
语法:
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
--结束END--
本文标题: mysql中如何添加排序名
本文链接: https://lsjlt.com/news/116197.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0