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