title: SELECT rows with minimum count(*)
body: <p>Let's say i have a simple table voting with columns </p>
  
  <pre><code>id(primaryKey),token(int),candidate(int),rank(int).
  </code></pre>
  
  <p>I want to extract all rows having specific rank,grouped by candidate and most importantly only with minimum count(*).
  So far i have reached</p>
  
  <pre><code>SELECT candidate, count( * ) AS count
  FROM voting
  WHERE rank =1
  AND candidate &lt;200
  GROUP BY candidate
  HAVING count = min( count )
  </code></pre>
  
  <p>But,it is returning empty set.If i replace min(count) with actual minimum value it works properly.
  I have also tried </p>
  
  <pre><code>SELECT candidate,min(count)
  FROM (SELECT candidate,count(*) AS count
        FROM voting
        where rank = 1
        AND candidate &lt; 200
        group by candidate
        order by count(*)
        ) AS temp
  </code></pre>
  
  <p>But this resulted in only 1 row,I have 3 rows with same min count but with different candidates.I want all these 3 rows.</p>
  
  <p>Can anyone help me.The no.of rows with same minimum count(*) value will also help.</p>
  
  <p>Sample is quite a big,so i am showing some dummy values</p>
  
  <pre><code>1 $sampleToken1 101 1
  
  2 $sampleToken2 102 1
  
  3 $sampleToken3 103 1
  
  4 $sampleToken4 102 1
  </code></pre>
  
  <p>Here ,when grouped  according to candidate there are 3 rows combining with count( * ) results </p>
  
  <pre><code>candidate count( * )
  
  101              1
  
  103              1
  
  102              2
  </code></pre>
  
  <p>I want the top 2 rows to be showed i.e with count(*) = 1 or whatever is the minimum</p>