sql语句如何实现分页?
整个数据是可以取出来的(量表用full join 之后按时间列排序 最终得到一个完整的“虚拟表”),sql语句如下
select * from(select * from Orders where Projectid=16) a full join (select * from PatientCome where RealProjectID=16) b on a.GUID = b.ComeGUIDorder by (case when DialogueTime is null then ComeTimeC else DialogueTime end) desc
类似这样select * from (select ROW_NUMBER() over(order by GUID )rn,* from tab )a where rn between 4 and 64、6 换成你的参数
[解决办法]
create proc usp_test @curr_page int, @page_row_num intasbegin set nocount on; select * from (select row_number() over (order by (case when DialogueTime is null then ComeTimeC else DialogueTime end) desc) as row_id, * from(select * from Orders where Projectid=16) a full join (select * from PatientCome where RealProjectID=16) b on a.GUID = b.ComeGUID) c where c.row_id > @page_row_num*(@curr_page - 1) and c.row_id <= @page_row_num*@curr_page;end;go