select count(1) from (select min(id) from table1 group by col1) a

解决方案 »

  1.   

    select *
    from T a
    where (select count(*) from T where a.col1 = col1) = 1select count(*) 
    from T a
    where (select count(*) from T where a.col1 = col1) = 1
    select col1
    from T 
    group by col1
    having count(*) = 1
      

  2.   

    to:klan
    假如表table1数据为
    id  col1  col2
    1    a     aaaa
    2    b     advad
    3    c     adad
    4    a      dddd用你写的语句能得到的结果为3嘛?
      

  3.   

    select count(distinct col1) from table
    --得到数目
    select distinct col1 from table
    --得到详单
      

  4.   

    select count(*) from 
    (
    select col1
    from T 
    group by col1
    having count(*) = 1
    ) emp
      

  5.   

    select count(*) from table1 group by col1
      

  6.   

    xiaoliaoyun(流浪的云) 的语句就很经典了。
      

  7.   

    select count(*) from table where (select count(*) from table where coll=table.coll)=1