关于row_number分页的存储过程,求帮忙啊
SET @strsql='select * from Card as R
left join(select revertid,cardid,revertperson,reverttime from Reverts Y where not exists(select 1 from Reverts where cardid=Y.cardid and revertid>Y.revertid ))T
on R.cardid=T.cardid left join(select cardid,count(*) as cardnum from Reverts group by cardid)W on R.cardid=W.cardid
where R.moduleid='+cast(@moduleid as nvarchar(50))+'']
查询出了一个关于帖子id、发帖人、最后一人回帖时间的结果集,我现在想要用row_number按照回帖时间reverttime进行分页排序,不知道该怎么进行,求达人帮忙。reverttime是在表Reverts中的
------最佳解决方案--------------------上面说的有问题 不好意思!!
看看下面可以么
SET @strsql='select row_number() OVER (order by Y.reverttime asc ) as number,* from Card as R left join(select revertid,cardid,revertperson,reverttime from Reverts Y where not exists(select 1 from Reverts where cardid=Y.cardid and revertid>Y.revertid ))T on R.cardid=T.cardid left join(select cardid,count(*) as cardnum from Reverts group by cardid)W on R.cardid=W.cardid where R.moduleid='+cast(@moduleid as nvarchar(50))+''
------其他解决方案--------------------有人可以帮帮忙吗
------其他解决方案--------------------
SET @strsql='select * from Card as R left join(select revertid,cardid,revertperson,reverttime from Reverts Y where not exists(select 1 from Reverts where cardid=Y.cardid and revertid>Y.revertid ))T on R.cardid=T.cardid left join(select cardid,count(*) as cardnum from Reverts group by cardid)W on R.cardid=W.cardid where R.moduleid='+cast(@moduleid as nvarchar(50))+''
------其他解决方案--------------------我现在查询出了所有的结果集,想要把这个结果集进行分页排序
------其他解决方案--------------------可以啊 把这个结果直接放在 With 中就可以了