Concatenating Certain Rows in Table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • firebirds98
    New Member
    • Feb 2008
    • 15

    Concatenating Certain Rows in Table

    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

    Code:
    CourseName          Progressionorder
    Class 1                          1
    Class 2                          2
    Class 3-A                        3
    Class 3-B                        3
    Class 3-C                        3
    Class 4-A                        4
    Class 4-B                        4
    I want to have a select statement in which will return

    Code:
    Class 1
    Class 2
    Class 3-A, Class 3-B, Class 3-C 
    Class 4-A, Class 4-B
    The rows that should be concatenated are the rows with the same progression order.

    Thank You in advance
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by firebirds98
    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

    Code:
    CourseName          Progressionorder
    Class 1                          1
    Class 2                          2
    Class 3-A                        3
    Class 3-B                        3
    Class 3-C                        3
    Class 4-A                        4
    Class 4-B                        4
    I want to have a select statement in which will return

    Code:
    Class 1
    Class 2
    Class 3-A, Class 3-B, Class 3-C 
    Class 4-A, Class 4-B
    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 Progressionorde r > 1. Union it with those with Progressionorde r = 1.

    -- CK

    Comment

    Working...