mysql如何每个分类取最新一条数据

现有如下数据

type time

2 2014-07-12
2 2014-08-14
3 2014-08-10
4 2014-08-03
4 2014-08-11
1 2014-08-12
1 2014-07-13
1 2014-08-15
要取出如下数据,按照type升幂,time降幂

type time
1 2014-08-15
2 2014-08-14
3 2014-08-10
4 2014-08-11
sql语句怎样写最简单快捷

第1个回答  2014-08-12
先排序 再 用 group by 取

假设 table xxx

select * from
(select * from xxx order by time desc ) a
group by type
order by type本回答被提问者采纳