sql统计

select t.sponortype, decode(t.rulecode,'1001','a1001','1002','a1001','1003','v1001','1004','v1001') ,
2*count(2)  over(partition by decode(t.rulecode,'1001','a1001','1002','a1001','1003','v1001','1004','v1001')) as tcount,
count(a.id) as acount
 from t_promotion_activity t,t_promotion_info a,t_promotion_record b
where t.id=a.aid
and t.id=b.aid
group by rollup(t.sponortype,decode(t.rulecode,'1001','a1001','1002','a1001','1003','v1001','1004','v1001'));

你可能感兴趣的:(sql统计)