int startPage=1 //起始页
int endPage; //终止页
int pageSize=5; //页大小
int pageNumber=1 //请求页
startPage=(pageNumber-1)*pageSize+1
endPage=(startPage+pageSize);
select * from (select 字段1,字段2,字段3,字段4,字段5,rownumber() over(order by 排序字段 asc ) as rowid from 表名 )as a where a.rowid >= startPage AND a.rowid <endPage
//以下sql表示取5条数据 从1取到5
select * from (select dslsid,zzjgdm,frmc,frlx,mc,frzs,fddbrxm,clrq,frzch,nsrglm,swdjrq,bgbs,bgcz,bgrq,swdjjgdm,orgdeptname,nsrsbh ,rownumber() over(order by dslsid asc ) as rowid from FR_V_DSLS )as a where a.rowid BETWEEN 1 AND 6
不好意思,犯了个低级错误,上面的sql语句是有误的,原因在于对between and的错误理解
本人记得between and是包含前者,不包含后者,实验表明,between and 前后两者都包含。
所以上述语句应修改为:
select * from (select dslsid,zzjgdm,frmc,frlx,mc,frzs,fddbrxm,clrq,frzch,nsrglm,swdjrq,bgbs,bgcz,bgrq,swdjjgdm,orgdeptname,nsrsbh ,rownumber() over(order by dslsid asc ) as rowid from FR_V_DSLS )as a where a.rowid >= 1 AND a.rowid < 6
留着上面的语句加深印象。