sql2000分页请教
现有表PX_YH_KM (YK_ID为主键,YK_KM会有重复数据)
YK_ID YK_KM
1 11
2 10
3 7
4 10
5 9
6 11
. .
. .
select distinct a.YK_KM,b.num
from PX_YH_KM a,(select YK_KM,count(*) as num from PX_YH_KM group by YK_KM)b
where a.YK_KM=b.YK_KM order by b.num desc
可以查出 YK_KM 对应num出现的次数,根据num大小排序
怎么在这个的基础上实现分页查询
------解决方案--------------------
SQL code
--not exists 分页语句:
select top 10 number
from master..spt_values a
where type='p'
and not exists(
select top 10 number
from master..spt_values b
where type='p' and a.number=b.number and number<20)
--建议你把查询的结果放到临时表再写分页语句