Oracle中的SQL数据透视查询

时间:2014-03-21 13:05:47

标签: sql oracle pivot

我有一张这样的表:

name----address----type----value
 a      finland    color    120
 a      finland    wage     500

我想要的是将colorwage值显示为列:

name----address----color----wage
 a      finland     120     500

1 个答案:

答案 0 :(得分:3)

SELECT *
FROM   (SELECT name, address, type, value
        FROM   table)
PIVOT  (SUM(value)  FOR (type) IN ('color', 'wage'));