select *
from t aa
where d=(select min(d) from t where a=aa.a)

解决方案 »

  1.   

    select a.* from t1 a,(select a,min(d) as d from t1 group by a)b
    where  a.a=b.aand a.d=b.d
    order by a.a
      

  2.   

    alter table yourtablename add id int identity(1,1)select * from yourtablename a 
        (select a,min(id) from yourtablename where a in (select a from yourtablenam group by a)
    group by a) b
    where a.a1=b.a and a.id=b.idalter table yourtablename drop id
      

  3.   

    alter table yourtablename add id int identity(1,1)select a. a,a.b,a.c,a.d from yourtablename a 
        (select a,min(id) from yourtablename where a in (select a from yourtablenam group by a)
    group by a) b
    where a.a1=b.a and a.id=b.idalter table yourtablename drop id
      

  4.   

    select identity(int,1,1) as id,* into #t from t1select a,b,c,d
    from #t
    where id in (select min(id) from #t group by a)
    order by a
      

  5.   

    select *
    from t1 a
    where d in (select top 1 d from t1 b where a.a=b.a order by d asc)
      

  6.   

    select *
    from t1 a
    where d in (select top 1 d from t1 b where a.a=b.a order by d asc)
      

  7.   

    select min(d),a from t1 group by a order by d
      

  8.   

    没看清楚要求,偶的错了一点,修改一下
    select min(d) d,a into #a from t1 group by a order by d
    go
    select * from t1,#a
    where t1.a=#a.a
    order by t1.a
      

  9.   

    declare @a
    declare aa_cursor cursor for
    select distinct a from tl
    open aa_cursor
    fetch next from aa_cursor into @a
    while @@fetch_status=0
    begin
    insert into #aa2 select top 1 a,b,c,d from tl where a=@a group by a,b,c,d order by dfetch next from aa_cursor into @cityend 
    select * from #aa2
    close aa_cursor
    DEALLOCATE aa_cursor
      

  10.   

    修改一下,
    declare @a varchar(3)
      

  11.   

    Select a.* from T1 
    where not exists (select 1 from T1 b where b.a<a.a)
      

  12.   

    declare @aa varchar(10)
    declare cur cursor for select distinct a from t1
    open cur fetch next from cur into @aa while @@fetch_status=0
      begin 
        select  top  1 * from t1 where a=@aa     
    fetch next from cur into @aa
     end
    deallocate cur