0
我有以下腳本,顯示從SYSDATE過去的11個月〜的Oracle SQL(Oracle11g中) - select語句哪裏日期等於另一個select語句
select * from (
select level-1 as num,
to_char(add_months(trunc(sysdate,'MM'),- (level-1)),'MM')||'-'||to_char(add_months(trunc(sysdate,'MM'),- (level-1)),'YYYY') as dte
from dual
connect by level <= 12
)
pivot (
max(dte) as "DATE"
for num in (0 as "CURRENT", 1 as "1", 2 as "2", 3 as "3", 4 as "4", 5 as "5",6 as "6",7 as "7",8 as "8",9 as "9",10 as "10", 11 as "11"))
我想創建一個表格,其中顯示交貨日期('MM-YYYY')等於上述腳本生成的日期的交貨數量。
我得到的交貨數量和交貨日期從以下
select dp.catnr,
nvl(sum(dp.del_qty),0) del_qty
from [email protected]_to_cdsuk dh,
[email protected]_to_cdsuk dp
where dp.dhead_no = dh.dhead_no
and dh.d_status = '9'
and dp.article_no = 9||'2EDVD0007'
and to_char(trunc(dh.actshpdate),'MM')||'-'||to_char(trunc(dh.actshpdate),'YYYY') = = --this is where I would like to match the result of the above script
group by dp.catnr
結果看起來是這樣的......
任何想法,將不勝感激。
感謝,SMORF