此代码输出一周中的不同日期,即mon、tue等。例如,输出可以仅为mon,或mon、tue、wed、thu和fri
school_days AS
(
SELECT to_char(trunc(sysdate ,'D') + LEVEL - sw.LEV_1, 'dy') as school_day
FROM SCHOOL_WEEKS sw
CONNECT BY LEVEL <= sw.LEV_2
),
此代码输出开始日期和结束日期之间的所有日期
all_dates AS
(
SELECT sw.sc_start_date + LEVEL-1 as weekday_date, to_char((sw.sc_start_date + LEVEL-1), 'DAY') as weekday_day
FROM SCHOOL_WEEKS sw
CONNECT BY sw.sc_start_date + LEVEL-1 <= sw.sc_end_date
)
如何只打印两个日期之间的选定日期?
SELECT * FROM all_dates
WHERE to_char(weekday_date, 'dy') IN ('output of school_days only')
1条答案
按热度按时间bpzcxfmw1#
将
schoolday_DATE
添加到第一个查询,然后根据DATE
数据类型值将它们连接起来: