469,582 Members | 2,556 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,582 developers. It's quick & easy.

transposing column data into columns

I have a table of populations of cities (identified by country, state,
cities) on particular dates. How do I transpose the date values in my
rows to a date value column that lists populations for that date. In
other words go from this:

Date Country State City Population
12/20 US IL Flora 1432
12/19 US IL Flora 1427
12/18 US IL Flora 1425
12/20 US AR Flora 1432
12/19 US AR Flora 1432
12/18 US AR Flora 1432
12/20 US AR Dan 1200
12/19 US AR Dan 1200
12/18 US AR Dan 1195

to this:
Country State City 12/20 12/19 12/18
US IL Flora 1432 1427 1425
US AR Flora 1432 1432 1432
US AR Dan 1200 1200 1195

Dec 20 '06 #1
1 1913
trizub wrote:
I have a table of populations of cities (identified by country, state,
cities) on particular dates. How do I transpose the date values in my
rows to a date value column that lists populations for that date. In
other words go from this:

Date Country State City Population
12/20 US IL Flora 1432
12/19 US IL Flora 1427
12/18 US IL Flora 1425
12/20 US AR Flora 1432
12/19 US AR Flora 1432
12/18 US AR Flora 1432
12/20 US AR Dan 1200
12/19 US AR Dan 1200
12/18 US AR Dan 1195

to this:
Country State City 12/20 12/19 12/18
US IL Flora 1432 1427 1425
US AR Flora 1432 1432 1432
US AR Dan 1200 1200 1195
Google for PIVOT in this newsgroup. This is a FAQ.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Dec 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Fabio | last post: by
8 posts views Thread by Leszek Gruszka | last post: by
reply views Thread by Christoph Lutz | last post: by
2 posts views Thread by Howard William | last post: by
6 posts views Thread by Hutty | last post: by
9 posts views Thread by Classic-Car-World Ltd | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.