select id,max(salary) from (select * from tableName order by id desc) group by department
select id,max(salary),distinct department from tableName order by id desc
文章来源: https://blog.csdn.net/sinat_41818709/article/details/91397957