如何取相同字duan值第一条记录??

时间:2022-11-29 05:59:06
表:a
id name
11 aaaa
11 bbbb
11 cccc
22 dddd
22 eeee
22 ffff

如何将表中的相同id号的第一条记录取出来?即:
id name
11 aaaa
22 dddd

select id1=identity(int,1,1),* into #t from a
go
select id,name from #t where id1 in(select min(id1) from #t group by id)

select * from a b
where name=(select top 1 name from a where id=b.id)