表taba数据如下:
colAcolBcolC
a1b11
a1b22
a1b34
a1b47
我想用一个用一个sql查询查出如下数据:
colAcolBcolC
a1b11
a1b22
a1null3
a1b34
a1null5
a1null6
a1b47
a1null8
sql语句如下:
selectnvl(t.cola,'a'),t.colb,lvfromtestt,(
selectlevelaslvfromdualconnectbylevel <=8)b
wheret.colc(+)=b.lv
----------------------------------------------------------------------------------------------
我要连续的8天数据,没有就选出来空的
aa2008/09/09
ab2008/09/10
ad2008/09/12
选出来之后把中间没有日期的补上
aa2008/09/09
ab2008/09/10
anull2008/09/11
ad2008/09/12
sql语句如下:
select t.cola,t.colb,lv from taba t,(
select to_date('2008/09/09','yyyy/mm/dd')+level as lv from dual connect by level <=8) b
where t.colc(+)=b.lv order by lv