By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,362 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,362 IT Pros & Developers. It's quick & easy.

Concatenating Certain Rows in Table

P: 15
I am trying to Concatene certain rows in a table but not all for instance

I have a Course Track that consits of the classes

Expand|Select|Wrap|Line Numbers
  1. CourseName          Progressionorder
  2. Class 1                          1
  3. Class 2                          2
  4. Class 3-A                        3
  5. Class 3-B                        3
  6. Class 3-C                        3
  7. Class 4-A                        4
  8. Class 4-B                        4
  9.  
  10.  
I want to have a select statement in which will return

Expand|Select|Wrap|Line Numbers
  1. Class 1
  2. Class 2
  3. Class 3-A, Class 3-B, Class 3-C 
  4. Class 4-A, Class 4-B
  5.  
  6.  
The rows that should be concatenated are the rows with the same progression order.

Thank You in advance
May 19 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
I am trying to Concatene certain rows in a table but not all for instance

I have a Course Track that consits of the classes

Expand|Select|Wrap|Line Numbers
  1. CourseName          Progressionorder
  2. Class 1                          1
  3. Class 2                          2
  4. Class 3-A                        3
  5. Class 3-B                        3
  6. Class 3-C                        3
  7. Class 4-A                        4
  8. Class 4-B                        4
  9.  
  10.  
I want to have a select statement in which will return

Expand|Select|Wrap|Line Numbers
  1. Class 1
  2. Class 2
  3. Class 3-A, Class 3-B, Class 3-C 
  4. Class 4-A, Class 4-B
  5.  
  6.  
The rows that should be concatenated are the rows with the same progression order.

Thank You in advance
I'll try to write your code later. You will need to be in sql2005. But here's the algorithm: Un/Pivot your table where the count of Progressionorder > 1. Union it with those with Progressionorder = 1.

-- CK
May 19 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.