select * from (
select row_number() over(order by id desc) as rowid,* from news
) tb where tb.rowid between 10 and 20
select * from (
select *,row_number() over(partition by (catalogid) order by [newsid] desc as t
from [newsIncatalog]
) a
where a.t<=5
order by catalogid,t
with 临时性视图(只对它下一条语句有效!)
with abc as(
select *,row_number() over(partition by (catalogid) order by [newsid] desc as t
from [newsIncatalog]
)
select * from abc where t=1 order by Catalogid,t
本文介绍使用SQL进行分页查询及创建临时性视图的方法。通过具体示例展示如何利用ROW_NUMBER()函数实现分页和视图,适用于快速定位数据及简化复杂查询场景。
774

被折叠的 条评论
为什么被折叠?



