上面的图像是我想要的输出,我希望它具有基于'净收入总计(net_ph)'的排名
PHP中的我的代码
SELECT artist, label, SUM(net_ph) as net_ph from believe_tb where accounts_of='$cid2' group by artist, label
您可以使用如下查询:
选择艺术家,标签,RANK()OVER(按ORDER BY SUM(net_ph)desc)作为排名,SUM(net_ph)作为net_ph,来自artist_tb,按艺术家,标签分组;
希望这会有所帮助。有关RANK()函数的更多信息:https://www.mysqltutorial.org/mysql-window-functions/mysql-rank-function/