求简单SQL语句,号码重复的,最时间最大的记录
id sj
1 45
1 65
1 76
2 98
2 65
3 64
4 12
4 25
id 重复的,只取SJ最大的记录
id sj
1 76
2 98
3 64
4 25
------解决方案-------------------- select *
from table01 a
where not exists (select 1 from table01 b where a.id=b.id and a.sj <b.sj)
------解决方案--------------------select id,max(sj) from tt group by id
------解决方案--------------------select id,max(sj) sj from 表 group by id
------解决方案--------------------select id,max(sj) from t group by id
------解决方案--------------------select id ,max(sj) as sj from tb group by id
------解决方案--------------------select max(sj) from TABLE1 group by id