【发布时间】:2020-03-05 17:41:39
【问题描述】:
Hej 伙计们,有人可以在下面的查询中向我解释 NVL() 和 OR 之间的区别吗:
Select
count(*)
from SHIPMENTSTATUS
WHERE insert_date between trunc(sysdate) -2 and trunc(sysdate) -1 or update_date BETWEEN trunc(sysdate) -2 and trunc(sysdate) -1
行数:44937
和
Select
count(*)
from SHIPMENTSTATUS
where NVL(UPDATE_DATE, INSERT_DATE) between trunc(sysdate) -2 and trunc(sysdate) -1
行数:44782
为什么我们会有这种差异:155 行?我基于 nvl 构建了一些查询,并注意到该问题并打算切换到 OR,但我真的很想知道,为什么会有如此大的差异。谢谢解释
【问题讨论】:
标签: sql oracle date where-clause