日期:2014-05-17 浏览次数:20957 次
SELECT WM_CONCAT(CASE WHEN V_OPTION = '爱好' THEN T.V_CONTENT ELSE NULL END) COLUMN1,
WM_CONCAT(CASE WHEN V_OPTION = '年龄' THEN T.V_CONTENT ELSE NULL END) COLUMN2,
WM_CONCAT(CASE WHEN V_OPTION = '性别' THEN T.V_CONTENT ELSE NULL END) COLUMN3,
WM_CONCAT(CASE WHEN V_OPTION = '城市' THEN T.V_CONTENT ELSE NULL END) COLUMN4
FROM MY_TABLE T
GROUP BY T.V_NAME
select 姓名,
max(decode(选项,'爱好',答案)) 爱好,
max(decode(选项,'年龄',答案)) 年龄,
max(decode(选项,'性别',答案)) 性别,
max(decode(选项,'城市',答案)) 城市
from t group by 姓名;
with test as
(select '爱好' 选项, '篮球' 答案, 'bruce' 姓名
from dual
union all
select '年龄', '28', 'bruce'
from dual
union all
select '性别', '男', 'bruce'
from dual
union all
select '城市', 'wh', 'bruce'
from dual
union all
select '爱好', '足球', 'jack'
from dual
union all
select '年龄', '25', 'jack'
from dual
union all
select '性别', '男', 'jack'
from dual
union all