select a2,min(a1) a1,min(a3) a3,min(a4) a4,min(a5) a5 from tablename group by a2看你取大还是取小:)
select identity(int,1,1) as nowid,* into #temp from tablename go select * from tablename where nowid in (select min(nowid) from tablename group by a2)
上面寫錯了 select identity(int,1,1) as nowid,* into #temp from tablename go select * from tablename where nowid in (select min(nowid) from #temp group by a2)
select * from a aa where not exists (select 1 from a bb where aa.a2=bb.a2 and aa.a1<bb.a1)
go
select * from tablename where nowid in
(select min(nowid) from tablename group by a2)
select identity(int,1,1) as nowid,* into #temp from tablename
go
select * from tablename where nowid in
(select min(nowid) from #temp group by a2)