横表的纵表实例
1.需要更改为横表的纵表如下图所示横表要求结构为busi_code为表的各个信息显示字段名称:
2.更改横表后表结构如下图所示
Sql:注意字段使用和方法使用
select
org_id ,
sum(decode(t.busi_code,'GSM开户',t.count_200910,0)) GSM开户,
sum(decode(t.busi_code,'补卡',t.count_200910,0)) 补卡,
sum(decode(t.busi_code,'程控功能变更',t.count_200910,0)) 程控功能变更,
sum(decode(t.busi_code,'过户',t.count_200910,0)) 过户,
sum(decode(t.busi_code,'离网挽留',t.count_200910,0)) 离网挽留,
sum(decode(t.busi_code,'密码重置',t.count_200910,0)) 密码重置,
sum(decode(t.busi_code,'批量程控功能更改',t.count_200910,0)) 批量程控功能更改,
sum(decode(t.busi_code,'批量改套餐',t.count_200910,0)) 批量改套餐,
sum(decode(t.busi_code,'其他服务(其余所有的服务)',t.count_200910,0)) 其他服务
from tableName<表名> t
group by t.org_id