SQLServer分页


分页查询==>
方法1:
(ROW_NUMBER()函数)语句形式:
select * from (
select *,ROW_NUMBER() OVER (ORDER BY column_name) as rank from table_name
) as t where t.rank between 3000001 and 3000010

方法2 (利用IN)语句形式:
select top 10 * from tbl_name where FlightsDetailID in(
select top 10 FlightsDetailID from(
select top 3000010 FlightsDetailID from tbl_name order by FlightsDetailID
) as t order by t.FlightsDetailID desc
) order by FlightsDetailID

方法3 (利用Not In)语句形式:
select top 10* from tbl_FlightsDetail where FlightsDetailID not in (
select top 3000000 FlightsDetailID from tbl_FlightsDetail order by FlightsDetailID
) order by FlightsDetailID

方法4 定位法 (利用ID大于多少)语句形式:
select top 10 * from tbl_FlightsDetail where FlightsDetailID>(
select max(FlightsDetailID) from (
select top 3000000 FlightsDetailID from tbl_FlightsDetail order by FlightsDetailID
) as t
) order by FlightsDetailID

SQLServer分页,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。