我需要使用以下查询创建group by子句:
SELECT NAME, SUM(donationvalue) FROM tbl_pdm2k10_Donations GROUP BY NAME ORDER BY SUM(donationvalue) desc
但我想在左边的一栏返回我:1、2、3、4、5等。在MSSql中我会做
SELECT Row_Number() Over(order by SUM(donationvalue) desc), NAME, SUM(donationvalue) FROM tbl_pdm2k10_Donations GROUP BY NAME
这可能吗?
set @row:=0; SELECT @row:=@row+1 as row_numer, NAME, SUM(donationvalue) as total FROM tbl_pdm2k10_Donations GROUP BY NAME ORDER BY total desc