select* from (select id,max(seq_no)as seq_no from tb group by id)a join tb b on a.id=b.id and b.seq_no=a.seq_no
select * from 表名 A where not exists (select 1 from 表名 where seq_no>A.seq_No)
select id,max(seq_no) as seq_no from t group by id?
select id, seq_no=max(seq_no) from tbName group by id
select * from table t where not exists (select * from table where id=t.id and seq_no>t.seq_No)
create table T(id int, seq_no int, value char(1)) insert T select 1, 2, 'B' union all select 1, 1, 'A' union all select 2, 1, 'C' union all select 3, 3, 'F' union all select 3, 2, 'E' union all select 3, 1, 'D' union all select 4, 1, 'G' --1 select id, max(seq_no) as seq_no from t group by id--2 select * from T as A where not exists(select 1 from T where id=A.id and seq_no>A.seq_no)
from (select id,max(seq_no)as seq_no
from tb
group by id)a
join tb b on a.id=b.id and b.seq_no=a.seq_no
insert T select 1, 2, 'B'
union all select 1, 1, 'A'
union all select 2, 1, 'C'
union all select 3, 3, 'F'
union all select 3, 2, 'E'
union all select 3, 1, 'D'
union all select 4, 1, 'G'
--1
select id, max(seq_no) as seq_no from t group by id--2
select * from T as A
where not exists(select 1 from T where id=A.id and seq_no>A.seq_no)