select distinct name,sn from table1 
这样就对了

解决方案 »

  1.   

    select name,sn=max(sn) from table1 group by name
      

  2.   

    declare @tb1 table([name] varchar(10),sn varchar(10))
    insert into @tb1
    select 'AB',         '123' union all
    select 'AB',         '456' union all
    select 'AB',         '456' union all
    select 'AC',         '789' union all
    select 'AD',         '789'select [name],sn=max(sn) from @tb1 group by [name]/*
    name       sn         
    ---------- ---------- 
    AB         456
    AC         789
    AD         789(所影响的行数为 3 行)
    */
      

  3.   

    select distinct name ,sn from table1