新手求一SQL语句
小弟是新手,请帮忙,源表:
id name time
1 n1 t1
2 n2 t2
3 n1 t3
4 n3 t4
5 n2 t5
我想得到:不重复的name 时间是最新的
类似于
id name time
5 n2 t5
3 n1 t3
4 n3 t4
------解决方案--------------------select * from t_name where time in
(select max(time) from t_name group by time)
------解决方案--------------------select * from tempTab where id in(select max(id) from tempTab group by name)
------解决方案--------------------select * from t_name where time in
(select max(time) from t_name group by name)