Select max( date) from t1 t where a.calendar_ date= t.date
当月份在周末或假日结束时,此查询会产生问题。此查询与另一个表连接,因此我需要一个查询,通过它我可以获得正确的日期。
发布于 2021-05-22 15:02:33
“度假”很难,因为它们是地区性的,每年都会发生变化。您应该保留一个满是假日日期的表,这样您就可以使用以下内容排除它们:
Select max(date)
from t1 t
LEFT JOIN holidays h on t.date = h.date
where
h.date IS NULL AND --not a holiday
(1 + TRUNC (t.date) - TRUNC (t.date, 'IW')) NOT IN (6,7) AND -- not a weekend, regardless of region
a.calendar_date= t.date
我不知道你的a
别名是从哪里来的
https://stackoverflow.com/questions/67646608
复制相似问题