ID a  
1  A 
2  B  
3  C  
4  D  
5  E
6  A
7  A
8  B
9  B 
10 A
11 B
12 C
我想得到的数据是a字段有重复的数据且重复和大于2的和(8)和a字段有重复的数据或者不重复的不大于2的和(4)
应该怎么写
谢谢
分不多

解决方案 »

  1.   

    a字段,A,4条B,4条 这个和是8条,剩下的和是4条
      

  2.   

    ---大于2个的
    select a,count(*)as 重复个数 from t4 group by a having count(*) >1
      

  3.   


    select a,count(*)as 重复个数 from t4 group by a having count(*) >2
    select a,count(*)as 重复个数 from t4 group by  a having count(*) <=2
      

  4.   

    select sum(ct) from(select ct=count(1) from tb group by a having count(1)<=2)t
    select sum(ct) from(select ct=count(1) from tb group by a having count(1)>2)t