All pastes #383509 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-06 12:51 UTC
rendered paste body
select t0.pack_cod,t1.reg,t2.reg,t3.reg,t4.reg,t5.reg,t6.reg,t7.reg,t8.reg,t9.reg,t10.reg,t0.total
from
(select distinct(pack_cod),count(distinct(cust_cod)) as total from churn group by pack_cod) as t0,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='1' group by pack_cod) as t1,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='2' group by pack_cod) as t2,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='3' group by pack_cod) as t3,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='4' group by pack_cod) as t4,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='5' group by pack_cod) as t5,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='6' group by pack_cod) as t6,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='7' group by pack_cod) as t7,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='8' group by pack_cod) as t8,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='9' group by pack_cod) as t9,
(select pack_cod,count(reg) as reg from churn where status='churn' and no_of_mon=2 and reg='G' group by pack_cod) as t10
cross join dim_region.pack_cod as t where
t1.pack_cod=t.pack_cod and t2.pack_cod=t.pack_cod and t3.pack_cod=t.pack_cod and t4.pack_cod=t.pack_cod and t5.pack_cod=t.pack_cod and t6.pack_cod=t.pack_cod and t7.pack_cod=t.pack_cod and t8.pack_cod=t.pack_cod and t9.pack_cod=t.pack_cod and t10.pack_cod=t.pack_cod,t0.pack_cod=t.pack_cod
group by t0.pack_cod,t1.reg,t2.reg,t3.reg,t4.reg,t5.reg,t6.reg,t7.reg,t8.reg,t9.reg,t10.reg,t0.total;