union起来再求和
select 区号,sum(呼叫总量) from
(select substr(bj,1,4) as 区号,count(*) as 呼叫总量 from call
group by substr(bj,1,4))
union all
(select substr(zj,1,4) as 区号,count(*) as 呼叫总量 from call
where th=950000
group by substr(zj,1,4))
group by 区号;
select 区号,sum(呼叫总量) from
(select substr(bj,1,4) as 区号,count(*) as 呼叫总量 from call
group by substr(bj,1,4))
union all
(select substr(zj,1,4) as 区号,count(*) as 呼叫总量 from call
where th=950000
group by substr(zj,1,4))
group by 区号;
decode(substr(bj,1,4),null,substr(zj,1,4),substr(bj,1,4)) as 区号,
count(*) as 呼叫总量
from
call
group by
decode(substr(bj,1,4),null,substr(zj,1,4),substr(bj,1,4))
decode(th,'950000',substr(zj,1,4),substr(bj,1,4)) as 区号,
count(*) as 呼叫总量
from
call
group by
decode(th'950000',substr(zj,1,4),substr(bj,1,4))
decode(th,'950000',substr(zj,1,4),substr(bj,1,4)) as 区号,
count(*) as 呼叫总量
from
call
group by
decode(th,'950000',substr(zj,1,4),substr(bj,1,4))