我有一张这样的表:
name----address----type----value
a finland color 120
a finland wage 500
我想要的是将color
和wage
值显示为列:
name----address----color----wage
a finland 120 500
答案 0 :(得分:3)
SELECT *
FROM (SELECT name, address, type, value
FROM table)
PIVOT (SUM(value) FOR (type) IN ('color', 'wage'));