开发者

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

开发者 https://www.devze.com 2023-01-21 16:18 出处:网络
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

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. "开发者_Go百科if the name column repeats, give me the first record with this repetition."


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

精彩评论

暂无评论...
验证码 换一张
取 消