我尝试查找2个日期之间的所有日期,并且在这里有一个查询
with tmp as(
select 1 sno, to_date('20181227', 'YYYYMMDD') curr_date, to_date('20181231', 'YYYYMMDD') curr_date2 from dual
union all
select 2 sno, to_date('20181227', 'YYYYMMDD'), to_date('20181231', 'YYYYMMDD') from dual
)
SELECT sno, curr_date + level - 1 DAY, LEVEL
FROM tmp
CONNECT BY curr_date + level -1 <= curr_date2
但是我收到了重复的结果,但由于缺少START WITH
子句here而被发现,但是我不知道START WITH
在哪里!
我仍然找不到任何解决方案来删除结果中的重复项。
答案 0 :(得分:1)
使用prior + sys_guid
方法。
...
CONNECT BY curr_date + level -1 <= curr_date2
and prior sno = sno
and prior sys_guid() is not null;