Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2011
    Posts
    220

    Unanswered: String concatenation

    Hi,

    DB2 V9.1 Z/OS

    The select query has to join three tables and need to give concatenated resultsets
    Code:
    SELECT
      T1.ID,
    T1.ID_NUM,
    T2.DIST_CD,
    T3.DIST_DES
      FROM
        BASE_TABLE T1
     INNER JOIN
        MASTER_TABLE  T2
      ON
     T1.ID   = T2.ID
     T1.ID_NUM = T2.ID_NUM
    INNER JOIN
      DIST_TABLE T3
     ON
       T2.DIST_CD = T3.DIST_CD
    Code:
    MASTER_TABLE
    
    ID  ID_NUM  DIST_CD 
    
    AA   A111    BEN
    AA   A111    BDD
    AA   B222    C1N
    BB   C121    DD1
    
    
    BASE_TABLE
    
    ID  ID_NUM
    AA   A111
    AA   B222
    BB   C121
    
    
    DIST_TABLE
    
    DIST_CD   DIST_DES
    BEN        BENTAT
    BDD        FWETAS
    C1N        COURTS
    DD1        NEWSAA
    EXPECTED RESULT SET

    Code:
    ID    ID_NUM   DIST_CD   DIST_DES
    AA    A111     BEN;BDD   BENTAT;FWETAS
    AA    B222     C1N       COURTS
    BB    C121     DD1       NEWSAA
    Thanks,

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    just search this forum for pivot/unpivot
    this has been requested different times and also answered
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Posting Permissions

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