AloneInTheDark
AloneInTheDark

Reputation: 938

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

Upvotes: 2

Views: 179

Answers (1)

MikkaRin
MikkaRin

Reputation: 3084

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

Upvotes: 3

Related Questions