Results 1 to 7 of 7

Thread: Sql ?

  1. #1
    Join Date
    Jun 2003
    Posts
    3

    Question Sql ?

    I have a table with the many records similar to the following:
    -----TEST------
    COL1 COL2
    ------ ------
    Test1 A
    Test1 B
    Test1 C
    Test1 D
    Test2 A
    Test2 B
    Test2 C

    Is there an SQL statement that would return the result:
    COL1 CONCATCOL2
    ------ -----------
    Test1 ABCD
    Test2 ABC

    Thanks for any help you may be able to provide.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You have to use a cursor for that. There is no CONCATENATION function similar to SUM in T-SQL.

  3. #3
    Join Date
    Mar 2003
    Posts
    468
    i have had good success with table functions (Oracle9i) for simplifying the SQL around this type of problem.

  4. #4
    Join Date
    Jun 2003
    Posts
    3
    Would either of you be able to give an example?

  5. #5
    Join Date
    Mar 2003
    Posts
    468
    hate to make you wait but there will be an example in an article i wrote right here on DatabaseJournal within the next day or two.

  6. #6
    Join Date
    Mar 2003
    Posts
    468

  7. #7
    Join Date
    Jun 2003
    Posts
    3
    Thanks jkoopmann, unfortunately I am not using Oracle. I am using DB2 on an AS/400.

    Does anyone have an example of the cursor solution to this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •