在有主键的情况下
SELECT * FROM sa_request t WHERE t.logid IN ( SELECT MAX(logid) FROM sa_request GROUP BY caseid );
或者效率高些的
SELECT * FROM sa_request t WHERE EXISTS ( SELECT 1 FROM sa_request GROUP BY caseid HAVING MAX(logid) = t.logid );
在有主键的情况下
SELECT * FROM sa_request t WHERE t.logid IN ( SELECT MAX(logid) FROM sa_request GROUP BY caseid );
SELECT * FROM sa_request t WHERE EXISTS ( SELECT 1 FROM sa_request GROUP BY caseid HAVING MAX(logid) = t.logid );