SQL分页以及分页数据总条数

if(@type=‘Select_71’)
begin
begin tran
select *,(select count(1) from (select BFdate from PW_Booking
join IR_Account on PW_Booking.BID_Cart = IR_Account.Account_name
where BID_Cart like ‘%’+@BID_Cart+’%‘and BName like ‘%’+@BName+’%‘and BRoomID like ‘%’+@BRoomID+’%’
and BFYear like ‘%’+@BFYear+’%’ and BFMoney like ‘%’+@BFMoney+’%’
) c
) as count_Page from (
select top 100000 row_number() over(order by BookingID desc) ID,BookingID,AccountID,BID_Cart,BName
,(case when BSex=‘True’ then ‘男’ else ‘女’ end) ASex_Text
,(case when BSex=‘True’ then ‘LightSkyBlue’ else ‘pink’ end) ASex_Color
,BTelPhone,BRoomID,BFdate from PW_Booking
join IR_Account on PW_Booking.BID_Cart = IR_Account.Account_name
where BID_Cart like ‘%’+@BID_Cart+’%‘and BName like ‘%’+@BName+’%‘and BRoomID like ‘%’+@BRoomID+’%’
and BFYear like ‘%’+@BFYear+’%’ and BFMoney like ‘%’+@BFMoney+’%’
order by BookingID desc
) as table_BookingAndAccount
where ID between @Start_Page_vs and @End_Page_vs
select @@identity
commit tran
end

发布了115 篇原创文章 · 获赞 36 · 访问量 9882

猜你喜欢

转载自blog.csdn.net/weixin_44548307/article/details/103295435