select * from(select *,ROW_NUMBER() OVER(PARTITION BY type ORDER BY typeindex DESC) as numfrom test) twhere t.num = 1
https://www.cnblogs.com/lakeliu/p/11943946.html