Oracle10g行变列 (decode的用法)
数据库原来的数据:
修改后的数据:
select ball "球",sum(decode(type,'红',num,0)) "红",
sum(decode(type,'绿',num,0)) "绿",
sum(decode(type,'蓝',num,0)) "蓝"
from t_ball group by ball
到此结束!!!
Oracle10g行变列 (decode的用法)
数据库原来的数据:
修改后的数据:
select ball "球",sum(decode(type,'红',num,0)) "红",
sum(decode(type,'绿',num,0)) "绿",
sum(decode(type,'蓝',num,0)) "蓝"
from t_ball group by ball
到此结束!!!