试试select b.compid,min(count(*)) as cnt from B group by b.compid

解决方案 »

  1.   

    试试这个那select compid,min(cnt) from (
    select compid,count(*) as cnt from b group by b.compid )
      

  2.   

    不好意思,应该是把compid 去掉.
      

  3.   

    select compid ,count(empid) from b  group by compid
      

  4.   

    SELECT * FROM (SELECT COMPID,COUNT(*) COUN FROM B
    GROUP BY B.COMPID ORDER BY 2)
    WHERE ROWNUM < 2
      

  5.   

    SELECT * FROM (SELECT COMPID,COUNT(empid) COUN FROM B
    GROUP BY B.COMPID ) c where coun =(select min(count(empid)) from b group by compid)
      

  6.   

    另外只有在8版以上的ORACLE中动态视图才可以加ORDER BY
      

  7.   

    select compid from
    (select compid,count(*) sl from b group by compid ) t 
    where sl= (select min(count(*)) from b group by compid )