Side-by-side comparison of data by month in SQL

Posted by ScottR on Stack Overflow See other posts from Stack Overflow or by ScottR
Published on 2010-06-14T20:30:27Z Indexed on 2010/06/14 20:42 UTC
Read the original article Hit count: 119

Filed under:
|
|

I have table similar to the following:

Year | Product |  Value
2006   A          10
2006   B          20
2006   C          30
2007   A          40
2007   B          50
2007   C          60

I would like a query that would return the following comparison

Product | 2006 Value | 2007 Value
A         10           40
B         20           50
C         30           60

What are the options to do so? Can it be done without joins?

I'm working with DB2, but answers in all SQL types would be helpful.

© Stack Overflow or respective owner

Related posts about sql

Related posts about db2