我必须使用oracle schedule查找过去5个工作日。
Java Streams
请帮助我这种方式是正确的还是任何其他优化的方式。
答案 0 :(得分:1)
select level from dual connect by level <=7
为级别提供结果1..7。
使用此选项,选择过去七天并删除周六和周日:
select 'prev_weekday_' || rownum as prev_weekday, d.dt
from (select trunc(sysdate) - level dt,
to_char(sysdate - level, 'D') w_day
from dual
connect by level <= 7) d
where d.w_day <= 5
order by d.dt desc;
/*
prev_weekday_1 14.07.2017
prev_weekday_2 13.07.2017
prev_weekday_3 12.07.2017
prev_weekday_4 11.07.2017
prev_weekday_5 10.07.2017
*/
如果您需要列中的结果,请转到:
select *
from (select 'prev_weekday_' || rownum as prev_weekday, d.dt
from (select trunc(sysdate) - level dt,
to_char(sysdate - level, 'D') w_day
from dual
connect by level <= 7) d
where d.w_day <= 5
order by d.dt desc)
pivot(max(dt)
for prev_weekday in('prev_weekday_1' as prev_weekday_1,
'prev_weekday_2' as prev_weekday_2,
'prev_weekday_3' as prev_weekday_3,
'prev_weekday_4' as prev_weekday_4,
'prev_weekday_5' as prev_weekday_5));
/*
prev_weekday_1 prev_weekday_2 prev_weekday_3 prev_weekday_4 prev_weekday_5
14.07.2017 13.07.2017 12.07.2017 11.07.2017 10.07.2017
*/