首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql2000分页请问

2012-11-08 
sql2000分页请教现有表PX_YH_KM (YK_ID为主键,YK_KM会有重复数据)YK_IDYK_KM1112103741059611....select d

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 awhere 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)--建议你把查询的结果放到临时表再写分页语句 

热点排行