在 Oracle SQL 中介于日期和大于日期之间



下面是数据集和系统日期 - 10月3日

ITEM    Date_from   Date_to
1234    1/1/2018    9/1/2018
1234    1/1/2018    10/1/2018
1234    1/1/2018    10/4/2018
1234    1/1/2019    12/31/2019

我的查询:

select * from test_date where effect_to >= sysdate 
minus
select * from test_date where effect_to < sysdate ;

正确结果:

1234    1/1/2018    10/4/2018
1234    1/1/2019    12/31/2019

有什么更好的查询吗?

需要列出当前有效的日期,并且对将来的日期也有效。

我想你只是想要:

where effect_to > sysdate

或者也许:

where effect_to >= trunc(sysdate)

取决于最后日期是包含还是排除。

最新更新