title: What can an aggregate function do in the ORDER BY clause?
body: <p>Lets say I have a plant table:</p>
  
  <pre><code>id fruit
  1  banana
  2  apple
  3  orange
  </code></pre>
  
  <p>I can do these</p>
  
  <pre><code>SELECT * FROM plant ORDER BY id;
  SELECT * FROM plant ORDER BY fruit DESC;
  </code></pre>
  
  <p>which does the obvious thing.</p>
  
  <p>But I was bitten by this, what does this do? </p>
  
  <pre><code>SELECT * FROM plant ORDER BY SUM(id);
  SELECT * FROM plant ORDER BY COUNT(fruit);
  SELECT * FROM plant ORDER BY COUNT(*);
  SELECT * FROM plant ORDER BY SUM(1) DESC;
  </code></pre>
  
  <p>All these return just the first row (which is with id = 1). </p>
  
  <ol>
  <li>What's happening underhood?</li>
  <li>What are the scenarios where aggregate function will come in handy in <code>ORDER BY</code>?</li>
  </ol>