André Miranda
André Miranda

Reputation: 6588

How can I write this SQL SELECT query for this table?

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? I also need the ID column, even if I get the first occurrence of the element, e.g. "if the name column repeats, give me the first record with this repetition."

Upvotes: 0

Views: 131

Answers (1)

Fosco
Fosco

Reputation: 38506

select name, MIN(ID)
from aCertainTable
group by name

Upvotes: 13

Related Questions