SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 07-28-2008, 08:49 PM
Unregistered
 
Posts: n/a
Question ANY dialect question:

crosstab query in sql


Hi,

I'm trying to write a query to reorganize data from veritcal to horizontal.. I can do this in access using a crosstab query but hoping to find a way to do it in sql so I can join the results with another table in the database.

the data I'm trying to crosstab looks like below...

ID Title Data
1 A x
1 B 1
1 C 1/1/2008
2 A z
2 D 2
3 E B
4 E B
5 B 2

I want the resulting table to look like this:

ID A B C D E
1 x 1 1/1/2008
2 z 2
3 B
4 B
5 2


There being one ID for each row, Title values being the column headings and Data values being the data.

the values in Title and Data can be anything (both stored as text) and there are no fixed number of Titles, but for each ID they are unique.

Please let me know if this is something that is possible and if so how to get started. Thanks in advance!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Be the first to answer this question! Click on the 'Post Reply' button below.
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:59 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8