473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2086
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fabio | last post by:
Hello, is there any quite easy solution for the problem of transposing the rows into the columns? I have the following table with some data in it: dealer date 09.00 10.00 11.00 ...
8
by: Leszek Gruszka | last post by:
Hello! I need to transpose some columns into rows and rows into columns. I know, tha i can do it by cursor, but i don't know how make it... I read a lot about it, but still don't understand......
0
by: Christoph Lutz | last post by:
Hi, I would like to transpose a table in mysql. I have looked on the web for a while but nothing seems to fit the bill, so I just want to clarify if I have to write some php or if I can use a...
2
by: Howard William | last post by:
Help. I am a bit flummoxed by the problem of how to transpose "normalized" (in the database sense) data records into columns of for a data entry form, and then back again when the user is...
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
6
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The...
9
by: Classic-Car-World Ltd | last post by:
Hi, I have some data in a table in columns which I need to convert into rows. This is specification data for some tools etc. The data is currently in the following format: Product No, order,...
4
by: m.wanstall | last post by:
Hi there, I have a large table based around a CustomerNumber with various details about that customer (originally imported and augmented from an Exchange Server)...now, a single customer can...
11
by: Haydee Zimmerman | last post by:
Hoping someone can help me. I have 2 Access tables with a one to many relationship. the 1 side table holds the billing information, the many table side holds the billing id and modifier#. Now I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.