2

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

1 Answer 1

3
SELECT *
FROM   (SELECT name, address, type, value
        FROM   table)
PIVOT  (SUM(value)  FOR (type) IN ('color', 'wage'));
Sign up to request clarification or add additional context in comments.

1 Comment

I had to put single quotes around 'color' and 'wage', otherwise it produces a "non-constant expression is not allowed for pivot|unpivot values" error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.