select distinct *
into table1
from table 
go
select *
from table1
order by b

解决方案 »

  1.   

    首先你要明确在选择B列时是最大的,最小的,要保证你的选择原则产生唯一的结果.并且排序的依据是你选择B列的结果而不是B列
    create table guo (id int,name varchar(1));
    records:
    id name
    1  a
    1  b
    2  a
    2  b
    3  a
    3  b
    3  c
    4  b
    select id,min(name) from guo group by id order by min(name)
    resultid name
    --------
    1  a
    2  a 
    3  a
    4  b
      

  2.   

    谢谢两位的光临
    对于LXDZZH:我只是根据A字段来去掉重复,而不关心B字段是否重复
    对于guo:我试了一下,好像可以的,谢谢了
      

  3.   

    select A from (select A,B from tablename group by A) order by B;
      

  4.   

    select A from table group by A order by B