title: SQL finding minimum that is non-zero
body: <p>I have issues finding the minimum values that are non-zero.</p>
  
  <p>For example, I have a table that show the amount of money earned by each person, and some of them don't earn anything. I would like to exclude those that don't earn anything and find the names of people who earn the least (that is non-zero).</p>
  
  <p>I tried this:</p>
  
  <pre><code>SELECT name, earnings
  FROM paylist
  WHERE earnings = (SELECT min(earnings)
              FROM paylist) AND EXISTS (SELECT * 
                                           FROM paylist
                                           WHERE earning &lt;&gt; 0)
  </code></pre>
  
  <p>But I realised that the min(earnings) will just become 0 and return no values in the output.
  How should I go about writing the query?</p>
  
  <p>Also, I am told there could be two ways to write this: 
  1. with aggregate functions (e.g. COUNT, SUM, MAX, MIN)
  2. without using any aggregate functions
  What's the difference?</p>