下面的查询从表中获取从第 10 行开始到第 20 行结束的行子集。此外,要保存查询,我需要返回表中的总行数。这是我能想到的最好的解决方案。有没有更高效/优雅的方式?特别是,我不喜欢这个partition by 1
部分。
select *
from (select count(*) over (partition by 1) as [count],
row_number() over (order by [Name],[Description]) as [row],
*
from [Products]) as t
where row between 10 and 20