April 1, 2009 at 1:40 am
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
April 1, 2009 at 2:28 am
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/61537April 1, 2009 at 3:58 am
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