?
Solved

T-SQL Translate data

Posted on 2008-10-27
4
Medium Priority
?
440 Views
Last Modified: 2012-05-05
Hi,  How can I translate data from a table to show up in a query in this manner:
Data  in table is like this:
Ed, 3
Ed, 2
Ed, 1
Ed, 4
Bob, 3
Bob, 2
Bob, 1
Bob, 4

output query to look like this:

Ed, 1, 2, 3, 5
Bob, 1, 2, 3, 4

Any help much appreciated.

Thanks.
0
Comment
Question by:sublimation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22811066
please see this article for the implementation of a function to do that (the 1,2,3,4 going into 1 column!)
http://anthony-yio.blogspot.com/2007/12/mssql-groupconcat.html

the alternative (for sql 2000, for example) would be a dedicated function:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=33574
0
 
LVL 4

Author Comment

by:sublimation
ID: 22812340
Hi,

The 1,2,3,4 goes into 4 separate columns.  The example reference is not very clear.  was hoping for some sql code/pseudo code.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22812500
you will have to specify more, especially as you want several columns output.
please clarify a bit more about the input/output.
0
 
LVL 4

Accepted Solution

by:
sublimation earned 0 total points
ID: 22819767
Hi, Angel.

I have found a solution now thanks.  The column names do not matter, you can see a clear example of translation.  We can call the columns col1, col2, col3, just as long as the data is translated in the manner shown.

The way to do it was to create a join on the same table numerous times (for each column required).

Thanks for your help
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question