我有一个这样的表:
ID|Name|Issue|Location 1 |01 |A |..... 2 |01 |B |..... 3 |02 |A |..... 4 |02 |B |..... 5 |02 |C |..... 6 |03 |A |.....
I want query that will return the id,name,issue,location for the max(issue) for each like :
2 |01 |B |.....
5 |02 |C |.....
6 |03 |A |.....
谢谢
最佳答案
select t.*
from tab t
join (
select name, max(issue) as issue
from tab
group by name
) t1 on t.name = t1.name and t.issue = t1.issue
关于SQL查询之谜,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8654670/