0
我被卡住了,請幫助我如何顯示每週的封面日期(例如星期一,星期二等)。請幫幫我。謝謝!如何在oracle中顯示1周的日期?
所需的採樣輸出:
Data,03/24/2014,Monday,20,Tuesday,30.....
Data,03/31/2014,Monday,12,Tuesday,20.....
這裏是我的腳本:
select 'Data'
||','||to_char(d.dtime_day, 'MM/dd/yyyy')
||','||nvl(g.total, 0)
from tablename d
left join (
select trunc(t.create_time, 'IW') as ddate
,count(t.create_time) as total
from tablename1 t
left join tablename2 q
on q.id = t.queue_id
where t.create_time between trunc(sysdate,'IW')-12*7 and sysdate -1
and q.name not like 'Data1%'
or q.name not like 'Data2%'
or q.name not like 'Data3%'
or q.name not like 'Data4%'
or q.name not like 'Data5%'
or q.name not like 'Data6%'
or q.name not like 'Data7%'
or q.name not like 'Data8%'
or q.name not like 'Data9%'
group by trunc(t.create_time, 'IW')
) g on d.dtime_day = g.ddate
where d.dtime_day between trunc(sysdate,'IW')-12*7 and trunc(sysdate) -1
and trunc(d.dtime_day, 'IW')= d.dtime_day
order by d.dtime_day;
輸出腳本:
Data,03/24/2014,42
Data,03/31/2014,25
我想這正是我們所需要的 – pablomatico
@ChrisProsser抱歉,這不是正是我需要的。我想顯示7天。例如我有這個查詢||','|| to_char(d.dtime_day,'MM/dd/yyyy'),所以它顯示日常日期,我有這個查詢d.dtime_day之間trunc(sysdate,'IW')每週顯示一次。我需要的是顯示每週覆蓋的日期 – yingyang
@Yang這些日子需要顯示爲列還是可以顯示爲行? – ChrisProsser