【发布时间】:2015-04-14 17:53:10
【问题描述】:
我有以下代码,它提供了三十天的生产日期和生产量。
select
(case when trunc(so.revised_due_date) <= trunc(sysdate)
then trunc(sysdate) else trunc(so.revised_due_date) end) due_date,
(case
when (case when sp.pr_typ in ('VV','VD') then 'DVD' when sp.pr_typ in ('RD','CD')
then 'CD' end) = 'CD'
and (case when so.tec_criteria in ('PI','MC')
then 'XX' else so.tec_criteria end) = 'OF'
then sum(so.revised_qty_due)
end) CD_OF_VOLUME
from shop_order so
left join scm_prodtyp sp
on so.prodtyp = sp.prodtyp
where so.order_type = 'MD'
and so.plant = 'W'
and so.status_code between '4' and '8'
and trunc(so.revised_due_date) <= trunc(sysdate)+30
group by trunc(so.revised_due_date), so.tec_criteria, sp.pr_typ
order by trunc(so.revised_due_date)
我遇到的问题是没有计划生产的日期,该日期不会出现在报告中。有没有办法补缺日期。
即当前报告显示以下内容...
DUE_DATE CD_OF_VOLUME
14/04/2015 35,267.00
15/04/2015 71,744.00
16/04/2015 20,268.00
17/04/2015 35,156.00
18/04/2015 74,395.00
19/04/2015 3,636.00
21/04/2015 5,522.00
22/04/2015 15,502.00
04/05/2015 10,082.00
注意:缺少日期(20/04/2015、23/04/2015 至 03/05/2015)
范围始终是从 sysdate 开始的 30 天。 如何填写缺失的日期? 您需要某种日历表吗?
谢谢
【问题讨论】:
-
是的,只需使用日历视图或子查询。看到这个问题:stackoverflow.com/questions/8374959/…