oracle改月份,ORACLE 月份不全,补全月份的sql | 学步园
select a.month, nvl(b.amount,0) amount--decode(b.amount,'',0)from (select to_char(sysdate, 'yyyy') || lpad(level, 2, 0) monthfrom dualconnect by level < 13) a,(select to_char(((sum(t.txn_amt) + sum
select a.month, nvl(b.amount,0) amount
--decode(b.amount,'',0)
from (select to_char(sysdate, 'yyyy') || lpad(level, 2, 0) month
from dual
connect by level < 13) a,
(select to_char(((sum(t.txn_amt) + sum(t.coupon_amt)) / 100),
'FM999,999,999,990.90') amount,
substr(t.inst_date, 0, 6) month
from t_log_acct_auth t
where t.confirm_flag = 'Y'
and t.cancel_flag = 'N'
and t.return_flag = 'N'
and substr(t.inst_date, 0, 4) = to_char(sysdate, 'yyyy')
group by substr(t.inst_date, 0, 6)) b
where a.month = b.month(+) order by a.month
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)