Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    47

    Unanswered: distinct colname

    v.7 DB2

    I am trying to get a DISTINCT list of colnames
    AND which tables they are first found in
    example: (This is what I do NOT want-see the colanmes are repeated)

    colname tabname
    c_1 x
    c_2 x
    c_3 y

    colname tabname
    c_1 x
    c_2 x
    c_1 y
    c_3 y


    here is my SQL:

    SELECT colname,tabname
    FROM SYSCAT.COLUMNS
    WHERE TABSCHEMA ='ZW'
    group by colname
    order by colname

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You were very close, try:

    SELECT colname,min(tabname)
    FROM SYSCAT.COLUMNS
    WHERE TABSCHEMA ='ZW'
    group by colname
    order by colname

    HTH

    Andy

Posting Permissions

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