求一分页SQL语句(在线等)
有一个表有10000多条记录如下
name price(消费) levels(级别)
1 201 金 (此记录级别应为白金)
2 320 白金 (此记录级别应为钻)
3 198 金
4 230 白金
5 320 钻
注:金(小于200) 白金(200-300) 钻(大于300)
现在要把
类似1,2的记录找出来,要求带分页功能。。
name price(消费) levels(级别)
1 201 金 (此记录级别应为白金)
2 320 白金 (此记录级别应为钻)
3 198 金
4 230 白金
5 320 钻
注:金(小于200) 白金(200-300) 钻(大于300)
现在要把
类似1,2的记录找出来,要求带分页功能。。
作者: sky1314 发布时间: 2011-06-11
SQL code
with cte as ( select *,px = row_number() over (order by getdate()/*或其他字段*/) from tb where --条件 ) select name,price,levels from cte where px between /* (pagesize*(pagenum-1)+1) */ and /* pagesize*pagenum */
作者: AcHerat 发布时间: 2011-06-11
楼上的朋友,能不把 from tb
where --条件
条件写一下呢,谢谢
where --条件
条件写一下呢,谢谢
作者: sky1314 发布时间: 2011-06-11
SQL code
select name,price,levels=(case when price<200 then '金' when price<=300 then '白金' when price>300 then '钻') from tb
作者: zy112429 发布时间: 2011-06-11
把#3的数据嵌套到#1的分页中,即可。
作者: maco_wang 发布时间: 2011-06-11