tags:

views:

39

answers:

1

I have this situation in a certain table:

id   |    name
1        'Test'
2        'Test'
3        'Test'

How can I make a query to select by distinct the name, but I also need the id column... even if I get the first occorrency of the element... something like, "if the name column repeats, give me the 1st record with this repetition"...

Is this possible?

Thanks!!

+11  A: 
select name, MIN(ID)
from aCertainTable
group by name
Fosco
+1 for nifty answer.
mohang
Thaaaanks Fosco! It works! :-)
AndreMiranda