日期:2014-05-18 浏览次数:20563 次
select * from(select * from Orders where Projectid=16) a full join (select * from PatientCome where RealProjectID=16) b on a.GUID = b.ComeGUID order 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 6 4、6 换成你的参数
------解决方案--------------------
create proc usp_test @curr_page int, @page_row_num int as begin 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