select a,max(b) as b ,max(c) as c from yourtable group by a

解决方案 »

  1.   

    alter table 表 add id int identity
    goselect a.a,a.b,a.c 
    from 表 a,(select id=min(id) from 表 group by a)b
    where a.id=b.id
    goalter table 表 drop column id
      

  2.   

    --如果不改原表,则用临时表
    select id=identity(int),a,b,c into #t from 表
    select a.a,a.b,a.c 
    from #t a,(select id=min(id) from #t group by a)b
    where a.id=b.id
    drop table #t
      

  3.   

    我用了这个方法:
    select a,max(b) as b ,max(c) as c from yourtable group by a但是为何用 rs.recordcount 返回的是 -1 ??
    怎么统计选取出来的记录总数?
      

  4.   

    select count(tb.a) as recordcount from (select a,max(b) as b ,max(c) as c from yourtable group by a
    ) tb
      

  5.   

    select max(a),b,c from ……
      

  6.   

    zjcxc(邹建) 的答案不正确
    其实LoveSQL(努力奋斗ing)的
    :select a,max(b) as b ,max(c) as c from yourtable group by a应该可以达到要求!建议给分因为楼主的要求就是列a必须唯一,这样肯定是要去掉一些记录,而如何去掉一些记妹,也没要求
    所以用max() 或 min()