DCB分组汇总过程

--DCB分组汇总过程
insert into bs_dcb_counts(id,country,currency_unit,partner,isp,business,cntgamecode,cntmoney,partmoney,bsharkmoney,
totalavgmoney,partneravgmoney,pricermb,totalprice,totalrmbprice,cdate,month,year)
(
select seq_dcb_billcount.nextval,temp.* from (select c.cname country,c.currency_unit,l.palias partner,isp,l.buessies,
nvl(sum(l.gamecode),0) cntgamecode,
trunc(sum(l.priceLocal),3) cntmoney,
trunc(sum(l.pricePartner),3) partmoney,
trunc(sum(l.priceBshark),3) bsharkmoney,
trunc(sum(l.priceRMB),3) totalavgmoney,
nvl(trunc(sum(l.pricePartner)/sum(l.gamecode),3),0) partneravgmoney,
trunc(sum(l.priceRMB),3) pricermb,
trunc(sum(l.totalPrice),3) totalprice,
trunc(sum(l.totalrmbprice),3) totalrmbprice,
cdate,cmonth,cyear
from bs_account_dcb_view l,qgc_country c
where l.cname = c.cname
and l.cdate >= strtime
and l.cdate < endtime

group by l.cname,c.cname,c.currency_unit,cdate ,cmonth,cyear,l.palias,l.isp,l.buessies) temp
);
COMMIT;

原文地址:https://www.cnblogs.com/jessi/p/4742913.html