Urgent Help needed in Sybase query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chella
    New Member
    • Mar 2007
    • 51

    Urgent Help needed in Sybase query

    Hi Experts,
    I have a problem in writing a sybase query for the following scenario,


    My table has the following data,

    id name
    1 aa
    2 bb
    1 bb
    3 cc
    2 aa

    I want a query which will give me the following output...

    id name
    1 aa
    2 bb
    3 cc

    I mean here that the id field should be unique and the name field can any one from its group. for eg.
    for the id value 1 the name field can be either aa or bb....

    Hope the problem is clear.

    Thanks in advance,
    Chella
  • mabubakarpk
    New Member
    • Feb 2007
    • 62

    #2
    I dont familiar with sybase but this query is OK for SQL Server you can get idea from it

    Code:
     Select * from tablename where id in (Select id from tablename group by id)

    Comment

    Working...