Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Vertical to Horizontal

Status
Not open for further replies.

damipera

Technical User
Dec 1, 2005
134
GB
Hi guys,

Can you give me some SQL advice please? I have a small table in Access that looks like this:
Code:
ID  Item   Description  2000  2001 2003  DescriptionB  2000B  2001B   2003B
1   fruits  grapes       23    12   35       banana      31      33    14 
2   vegies  bean         53    14   17       spinach     16      55    21

How can I make it to look like this?

Code:
ID  Item    Description  2000  2001 2003  DescriptionB  2000B  2001B   2003B  Item   Description  2000  2001 2003  DescriptionB  2000B  2001B   2003B
1   fruits   grapes       23    12   35       banana      31      33    14    vegies    bean       53    14   17       spinach     16      55    21



 
My guess is you really don't want your data to look like you say you want it to look even if you really think you do. No offense meant.

Can you tell us a little more about the data? Are the 2001, 2003 etc years? Or maybe a location designation? Are the integer values usage or consumption of some sort? A little explanation of what we are looking at?

I ask these things and made my opening statement because your data looks suspiciously nonnormalized. In general, normalizing your data first makes subsequent queries and data manipulation a lot easier.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top