select query

  • I have a database table like below with 2 columns

     CCode, CName

     1A       John

     2A       Dean

     3A       Schel

     3A       Mahata

    Now i want to return the resultset from the query as

    CCode, CName

    1A      John

    2A      Dean

    3A      Schel

    (where I want to return values for all unique values for CCode column and its corresponding cname column)

    Thanks

  • Not too sure if you have a preference for what Name comes back in the query

    Eg : what name do you want for the 3A code, Schel or Mahata ?? Do you have a unique ID field in the table ???

    - This will pull back the code and one of the corresponding names ?

    SELECT CCode,MAX(CName)

    from TABLE

    GROUP BY CCode

    ORDER BY CCode

    Please give more info on table structure and desired result....

  •  

    select ccode,cname from tablename where (ccode,cname) not in (select ccode,cname from tablename A where rowid>(select min( rowid) from tablename B where A.ccode=B.ccode))

    I hope this will solve urs problem

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply