AloneInTheDark AloneInTheDark - 2 months ago 7
SQL Question

SQL pivot query in Oracle

I have a table like this:

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


what i want is to show
color
and
wage
values as columns:

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

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