日期:2014-05-17  浏览次数:20694 次

SQL语句书写
我的表结果如下:


想达到如下效果的SQL语句怎么写?
Oracle

------解决方案--------------------
select col1,case col2 when 'B1' then col3
------解决方案--------------------
';'
------解决方案--------------------
col4 end B1,
            case col2 when 'B2' then col3
------解决方案--------------------
';'
------解决方案--------------------
col4 end B2,
            case col2 when 'B3' then col3
------解决方案--------------------
';'
------解决方案--------------------
col4 end B3
from test3
------解决方案--------------------
不好意思,写错了一个关键字
select cola,case (when colb='B1' then colc
------解决方案--------------------
';'
------解决方案--------------------
cold else null) as B1,
case (when colb='B2' then colc
------解决方案--------------------
';'
------解决方案--------------------
cold else null) as B2,
case (when colb='B3' then colc
------解决方案--------------------
';'
------解决方案--------------------
cold else null) as B3 from table