当前位置: 代码迷 >> Oracle管理 >> SQL话语书写
  详细解决方案

SQL话语书写

热度:40   发布时间:2016-04-24 04:42:33.0
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
  相关解决方案