MySql 对排序后的记录进行排号
2020-06-23 本文已影响0人
Rinaloving
SELECT a.*, (@rowno:=@rowno+1) AS rowno FROM (SELECT SUM(sWeight) AS total, fkVip FROM TbPutGarbage GROUP BY fkVip ORDER BY total DESC) a,(SELECT (@rowno:=0)) b
排序.png
SELECT a.*, (@rowno:=@rowno+1) AS rowno FROM (SELECT SUM(sWeight) AS total, fkVip FROM TbPutGarbage GROUP BY fkVip ORDER BY total DESC) a,(SELECT (@rowno:=0)) b
排序.png