------解决方案-------------------- --sql 2005 select t.* , RANK() over(order by val desc) 排名 from ( select m.id , m.name , isnull(sum(n.amount* n.price),0) val from sale m left join product n on m.id = n.id group by m.id , m.name ) t
--sql 2000 select t1.* , (select count(val) from (select m.id , m.name , isnull(sum(n.amount* n.price),0) val from sale m left join product n on m.id = n.id group by m.id , m.name) t2 where t2.val > t1.val) + 1 from (select m.id , m.name , isnull(sum(n.amount* n.price),0) val from sale m left join product n on m.id = n.id group by m.id , m.name) t1
------解决方案-------------------- 这问题问过了么?
------解决方案--------------------