title: SQL group function nested too deeply
body: <p>I want to make a SQL query which finds the <code>pname</code> of parts which are the least repeated in   <code>supplier_parts_shipment</code>.</p>
  
  <p>Table 1 supplier (sno, sname, city)</p>
  
  <pre><code>1, ahmad, jeddah
  2,kaled,med
  3,njwa,med
  </code></pre>
  
  <p>Table 2 parts (pno, pname, color)</p>
  
  <pre><code>1, laptop, red
  2,keybord,blue
  </code></pre>
  
  <p>Table 3 supplier_parts_shipment (shno, sno, pno, date)</p>
  
  <pre><code>1,1,1,2014
  2,2,1,2014
  3,3,2,2014
  </code></pre>
  
  <p>I tried something like this:</p>
  
  <pre><code>  SELECT pname 
         , min(count(pno)) 
      FROM parts 
     WHERE pno IN (SELECT pno 
                     FROM supplier_parts_shipment 
                    group by 
                          pname 
                   HAVING min(count(pno))
                  )
  SQL&gt; /
  pno IN(SELECT pno FROM supplier_parts_shipment group by pname HAVING min(count(pno))))
                                                                           *
  ERROR at line 2:
  ORA-00935: group function is nested too deeply
  </code></pre>