oracle查询缺失数据
with tab as (
select '2001' d from dual union all
select '2002' d from dual union all
select '2003' d from dual union all
select '2006' d from dual union all
select '2007' d from dual union all
select '2008' d from dual)
SELECT SS
FROM (SELECT SN + (level - 1) SS
FROM (select min(d) SN,max(d) EN from tab) T
CONNECT BY SN + (level - 1) <= EN)
WHERE SS NOT IN (SELECT d FROM tab)
各位大神,这样数据大了好慢。有没有能快点的。
------解决方案--------------------分组查询,你是不是应该先分组再利用这个查询进行左关联来实现呢?