mysql 分组取max或min

select a.* from tbas_2016  a,(select mmsi, max(utc1) utc1 from tbas_2016 group by mmsi) b
where a.mmsi = b.mmsi and a.utc1 = b.utc1 order by a.mmsi


select a.mmsi, a.portid,a.utc1,a.utc2,a.utc3 from tbas_2016 a where
utc1 = (select max(utc1) from tbas_2016 where mmsi=a.mmsi) order by mmsi
posted @ 2016-07-19 14:13  云淡风轻~  阅读(818)  评论(0编辑  收藏  举报