mysql : 不能有最大结果

mysql : can't have the max result

我的 mysql 请求有问题,我有这个 table :

col1 id_sec _index
111 20 3
111 50 0
111 60 1
111 20 2
111 20 1
111 20 0
111 60 0

我想要:

col1 id_sec _index
111 60 1
111 50 0
111 20 3

但我有:

col1 id_sec _index
111 20 0
111 50 0
111 60 0

我的要求是:

select * 
from ( select * 
       from test 
       WHERE col1 = 111
       order by id_sec, _index desc
     ) t2 
group by id_sec 

感谢您的帮助!

SELECT col1, id_sec, MAX(_index) _index
FROM table
GROUP BY 1,2
ORDER BY 2 DESC;

https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=1e1155442ac7dcf3f54ba1fee5228078