tsq - 取重复行中的最高整数

tsq - take the highest int in duplicate row

我在 table

中有以下行
name, tagid
-------
test1,1
test1,100
test2,2
test2,200
test3,3
test3,300

名称中有重复项。 有没有办法通过获取每个组中最高的 tagid 来 select 唯一名称?

;WITH cte AS
(
   SELECT *, ROW_NUMBER() OVER (PARTITION BY name ORDER BY tagid DESC) AS rn
   FROM table_1
)
SELECT *
FROM cte
WHERE rn = 1
select name,max(tagid) as highest_tagid
from tbl
group by name