473,769 Members | 7,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2103
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
4723
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 12.00 13.00 14.00 ----------------------------------------------------------------- 1 2004-10-01 1/1 2/3 3/3 3/4 4/5 0/3 1 2004-10-02 0/1 1/3 1/3 1/4 3/5 1/3
8
2866
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... Can someone help me? *** Sent via Developersdex http://www.developersdex.com ***
0
1999
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 SQL query (preferred). What I would like to do is to use the values in a row as column headings during output, so that I can enter different sets of data into the same table and display it in a readable format afterwards. Let me explain: I have say...
2
6265
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 finished. My previous solution to this was to filter by query or SQL for the observations for a particular set of criteria, then go through the resulting records and assign them to a non-normalized work table containing ONE RECORD with the rows x...
6
5072
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 do with the 1st column ? (Below I have a "1" in place for now). Also, Does the datase.AcceptChanges(); updates the changes to the database? Which command do I use to update the changes in dataset back to the Access database table? Thanks, Alpha...
6
3841
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 first two columns are pretty much text column, but subsequent columns 1-12 are numerical. I'm trying to get the thousand separator to work. Any ideas?
9
10668
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, description, value 1000, 1, model No, Ak272 1000, 2, Size, 10mm 1000, 3, Length, 20mm 1001, 1, Model No, Ak273
4
1706
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 have many email addresses and thus will have multiple entries in this table but this isn't what I want. Is there a way to relatively simply take any duplicate CustomerNumber records, take their EmailAddress field and append it in a new column...
11
2192
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 need to transpose the data into: billing id, modifier1, and modifier 2. If I do a crosstab query I get different modifiers as column headings but I only want the 2 columns. for example: billing id modifier 1 modifier2 1100 50...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.