select  stor_id,count(*)   from  table
group  by  stor_id
having  count(*)  >  1 
order  by  stor_id

解决方案 »

  1.   

    Select Count(*) From 
    (select  stor_id  from  sales  where  ..group  by  stor_id  having  count(*)>1 )
    aa
      

  2.   

    select    stor_id,count(*)      from    table 
    group    by    stor_id 
    having    count(*)    >    1  
    order    by    1
      

  3.   

    select stor_id  from sales
    group  by  stor_id    
    having  count(*)> 1  
    结果为:stor_id
    6380
    7066
    7067
    7131
    7896
    8042
    而我要的结果是6,即上述结果的合计数,:warning(爱就爱了) ,:N_chow(一劍飄香++),:Eric2000(Eric2000的方法我发现都不能得到该结果。
      

  4.   

    Select Count(*) From 
     (select  stor_id    from  sales 
    group    by    stor_id        
    having    count(*)>  1 )
    aa
    不對嗎
      

  5.   

    N_chow(一劍飄香++) 的应该正确!是不是有空值?试试下面的:
    Select Count(*) From (select stor_id from sales  
                          group by stor_id                
                          having count(stor_id)>1) aa 
      

  6.   

    :N_chow(一劍飄香++)正确!谢谢了,给分!!!
      

  7.   

    Select  Count(*)  From  
      (select distinct    stor_id        from    sales  
    group        by        stor_id                
    having        count(*)>    1  ) 
    aa
      

  8.   

    呵呵,飄香兄怎么会写错呢,千万不要怀疑!!飄香兄,好久不见,有空关注一下
    http://www.csdn.net/expert/topic/562/562999.xml