create table A ( a int IDENTITY (1,1)NOT NULL, b varchar(10), c varchar(10) ) insert A select '001','1001' union select '001','2001' union select '002','1001' union select '003','1002' union select '003','2002' union select '004','1003'select b,max(c) from A group by b
select b,c=max(c) from 表 group by b
select b,max(c)as c from 表 group by b
select b,c=max(c) from 表 group by b
select * from A t where c=(select max(c) from A where b=t.b)
(
a int IDENTITY (1,1)NOT NULL,
b varchar(10),
c varchar(10)
)
insert A
select '001','1001' union
select '001','2001' union
select '002','1001' union
select '003','1002' union
select '003','2002' union
select '004','1003'select b,max(c) from A group by b
from 表
group by b
from 表
group by b
from 表
group by b
where c=(select max(c) from A where b=t.b)
from A
group by b
from 表
group by b