oracle 查询单列转单行
本帖最后由 tomorrowzm 于 2012-11-16 17:23:05 编辑
------最佳解决方案--------------------给你例子
CREATE TABLE t_row_col AS
SELECT 1 a, 'c1' cn, 10 cv
FROM dual
UNION ALL
SELECT 2 a, 'c2' cn, 20 cv
FROM dual
UNION ALL
SELECT 3 a, 'c3' cn, 30 cv FROM dual;
SELECT
MAX(decode(cn, 'c1', cv, NULL)) AS c1,
MAX(decode(cn, 'c2', cv, NULL)) AS c2,
MAX(decode(cn, 'c3', cv, NULL)) AS c3
FROM t_row_col