sql - 带 Where 子句的 OFFSET SQL 查询

我正面临一个关于 OFFSET 的奇怪问题(在 linq 中使用 skip)。当我使用 where 子句并过滤空值时,offset 以错误的顺序返回记录。

select * from ExpectedApplication where ApplicationId is null
order by PaymentDate desc 
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY 

select * from ExpectedApplication where ApplicationId is null
order by PaymentDate desc 
OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY 

输出是:

由于这个问题,我的分页结果返回了不正确的数据。请帮忙。非常感谢。

问候, 维维克

最佳答案

select * from (select * from ExpectedApplication where ApplicationId is null) as tbl
order by PaymentDate desc
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY

你可以这样尝试(使用子查询) 它对我有用。

https://stackoverflow.com/questions/34130403/

相关文章:

git - 为什么 cherry-pick 告诉我所有线路都已更改?

java - 收听 RabbitMQ 队列并获取事件通知

android - 带有 Snackbar 和透明导航栏的 FloatingActionButton

sql-server - 在 SQL Server 2012 的情况下,尝试在我的 select 语

node.js - 如何在 mongodb 中插入嵌套对象?

matrix - Spark RDD 到 Matrix

types - 如何声明 TypeScript 导入 * 类型?

java - 在 Apache Spark SQL 中对多行进行操作

d3.js - d3 中的自定义比例

android - 谷歌身份验证后,即将到来的网址不允许我在 Cordova 应用程序中走得更远