select distinct id,count
from table
group by id,count
==================================
结果是
015      2
017      1
017      2
017      3
018      2
019      2
================================
我想要的结果是
015      2
017      2 这个2是求id=017的平均值
018      2
019      2
==============================
在线等,急

解决方案 »

  1.   

    select id,avg(count) from (
    select distinct id,count 
    from table 
    group by id,count )
    group by id
      

  2.   

    select distinct id,AVG(count) 
    from table
    group by id
      

  3.   

    select id,avg([count]) [count] 
    from table 
    group by id
      

  4.   

    create table #tab (id varchar(10),col int)
    insert into #tab values('015',2)
    insert into #tab values('017',1)
    insert into #tab values('017',2)
    insert into #tab values('017',3)
    insert into #tab values('018',2)
    insert into #tab values('019',2)select id,col=avg(col) from #tab group by idid         col
    ---------- -----------
    015        2
    017        2
    018        2
    019        2(4 行受影响)
      

  5.   

    select id,avg(distinct count) from table group by id