Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    15

    Unanswered: How to return truncated data?

    Not sure if i titled it correctly but here is basically what I am trying to do:

    The statement below returns the behaves as follows:
    Code:
    SELECT c.DATA CUSTOMER, r.DATA ID_CODE  FROM CUSTNAME_TABLE c, ID_TABLE r 
    WHERE (c.INSTANCEID = r.INSTANCEID) ORDER BY CUSTOMER
    
    CUSTOMER         ID_CODE
    ----------     ----------
    CUST_A             100
    CUST_B             101
    CUST_B             102
    CUST_C             103
    CUST_C             104
    CUST_C             105
    CUST_D             106
    As you can see from the code above, both are linked by the "INSTANCEID" Column.

    But what I would like to do is create a statement that will return the data above as follows:
    Code:
    CUSTOMER         ID_CODE
    ----------     ----------
    CUST_A             100
    CUST_B             101,102
    CUST_C             103,104,105
    CUST_D             106

    thanks in advance,

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    There are several techniques; check this page which talks about string aggregation. Also, you might visit Ask Tom site and see what Tom Kyte said about it.

    If you decide to search by yourself, "STRAGG" might be the keyword you need.

Posting Permissions

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