
create table tab11 (
wrcvdate number,
year number(4),
month number(2),
day number(2),
flag number(1)
);
insert into tab11 (wrcvdate, year, month, day, flag)
values (20061228, 2016, 12, 28, 1);
insert into tab11 (wrcvdate, year, month, day, flag)
values (20061229, 2016, 12, 29, 1);
insert into tab11 (wrcvdate, year, month, day, flag)
values (20061230, 2016, 12, 30, 0);
commit;
select max(t.wrcvdate) 上一个工作日日期 from tab11 t where t.flag = 1 and t.wrcvdate < 20061231;
1.wrcvdate < 20061231:筛选所有早于20061231的日期。
2.flag = 1:仅选择工作日(flag=1)。
3.MAX(wrcvdate):取这些工作日中最接近20061231的日期(即上一个工作日)。

1198

被折叠的 条评论
为什么被折叠?



