Getting distinct records in SQL 2000

  • Hi All,

    I have a requirement to get distinct records along with the ID's as below example

    create table test

    ( id int identity(1,1) not null,

    name varchar(10)

    )

    insert into test values ('King')

    insert into test values ('Queen')

    insert into test values ('King')

    insert into test values ('Pawn')

    insert into test values ('Pawn')

    insert into test values ('King')

    insert into test values ('Queen')

    select distinct name from test;

    King

    Pawn

    Queen

    Can I get the id values or rowid too with the distinct name.

    Regards,

    Bimal

  • Which ID do you want?

    select name,max(id) as id

    from test

    group by name

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Thanks Mark for that.

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

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