首页 新闻 会员 周边 捐助

oracle 怎么求每个月的数据

0
悬赏园豆:20 [待解决问题]

怎么求每个月的数据
SELECT case a.ISSPEC when 10 then '新品快订' when 20 then '现货快补' when 80 then '海量内淘' when 100 then '云仓' end as XMMC,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=1 then 1 else 0 end as a,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=2 then 1 else 0 end as s,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=3 then 1 else 0 end as d,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=4 then 1 else 0 end as f,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=5 then 1 else 0 end as g,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=6 then 1 else 0 end as h,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=7 then 1 else 0 end as j,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=8 then 1 else 0 end as k,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=9 then 1 else 0 end as l,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=10 then 1 else 0 end as z,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=11 then 1 else 0 end as x,
case when TO_CHAR(to_date(month,nvl(a.DSJS,0)))=12 then 1 else 0 end as c
from
(select b.ISSPEC,count(a.id) as dssl,sum(TOT_NUM) as dsjs,sum(TOT_AMT_LIST) as dpje from B_FO a
left join B_FAIR b on a.B_FAIR_ID=b.id
left join C_STORE c on a.C_DEST_ID=c.id
where a.STATUS='2' and b.ISSPEC in (10,20,80)
group by b.ISSPEC
union all
select 100 as ISSPEC,count(a.id) as dssl,sum(a.dsjs) as dsjs,sum(a.dpje) as dpje from (
select a.id,sum(b.QTYOUT) as dsjs,sum(b.TOT_AMT_LIST) as dpje from O2O_SO a
left join O2O_SOITEM b on b.EB_ORDERSO_ID=a.id
left join C_STORE c on a.C_STORE_ID=c.id
where a.OUT_STATUS='2' and to_char(a.STATUSTIME,'YYYYMMDD')=to_char(sysdate,'YYYYMMDD')and c.C_BLOCK_ID=06
group by a.id ) a
) a

借口/*-的主页 借口/*- | 初学一级 | 园豆:10
提问于:2021-11-22 14:15
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册