group by rollup分组求合

select
od.Org_Province_Direct_Cd,od.Org_Province_Direct_Name,mcc.Industry_Cd,mcc.Industry_Name,
sum(Add_Sale_Amt),sum(Add_Sale_Num)
from V03_ACQ_VOL_STAT merVol,  T03_TIME_DIMENSION as tim ,T03_ORG_DIMENSION as od  ,T03_MCC_DIMENSION mcc
where od.Org_Key=merVol.Org_Key and   mcc.Industry_Key=merVol.Industry_Key and      tim.Time_Key=merVol.Time_Key
and exists (SELECT Org_Key FROM T03_ORG_DIMENSION as tod WHERE 1=1  AND merVol.Org_Key=tod.Org_Key)
and  tim.Full_Date_Key between '2008-04-17' and '2009-04-17'
group by rollup(od.Org_Province_Direct_Cd,od.Org_Province_Direct_Name, mcc.Industry_Cd,mcc.Industry_Name)

你可能感兴趣的:(group by)