×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Multiple Rows in 1 Row
2

Multiple Rows in 1 Row

Multiple Rows in 1 Row

(OP)
Hi there,

I am trying to return some data in Transact SQL. The small example table below shows the core data and the Example OutPut shows what I am trying to achieve. I want one row per Client however I cant think of a way to do this. Any ideas anyone.
Example Date

ClientNo SystemID Facility

0000002/001 0000002 Payments
0000002/001 0000002 Cheques
0000002/001 0000002 CHAPS
0000002/001 0000002 BACS
0000002/001 0000002 Cash

OutPut Data
SystemID Facility
0000002 Payments,Cheques,CHAPS,BACS,Cash

RE: Multiple Rows in 1 Row

Did you try to PIVOT your data?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: Multiple Rows in 1 Row

If what you're trying to do is create a single field with all those items comma-separated, take a look at the GROUP_CONCAT() function.

Tamar

RE: Multiple Rows in 1 Row

(OP)
Will try both thank you

RE: Multiple Rows in 1 Row

(OP)
I used STRING_AGG instead in the end - works lovely.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close