基本上,问题是如何从中获得答案:
group string 1 A 1 B 2 C
对此:
group string 1 B 2 C
B必须是组中的最后一行
答案 0 :(得分:0)
select [group], max(Id) as maxID
into ##grouped
from myTable
group by [group]
select t.[group], t.string
from myTable t
inner join ##grouped g
on g.id = t.id
答案 1 :(得分:0)
简单
SELECT `group`, MAX(string)
FROM tablename
GROUP BY `group`