日期:2014-05-18 浏览次数:20635 次
select name as 书籍名,count(1) as 借阅次数 from tb group by name order by 借阅次数 desc
------解决方案--------------------
--应该按照书籍名称(Name)进行统计吧? --sql 2000 select m.* , px = (select count(distinct cnt) from ( select Name , count(1) cnt from tb group by name ) n where n.cnt > m.cnt) from ( select Name , count(1) cnt from tb group by name ) m order by px --sql 2005 select m.* , px = RANK () OVER(order by cnt desc) from ( select Name , count(1) cnt from tb group by name ) m order by px