title: order by min() in sql
body: <p>I am new to oracle sql. I'm trying to understand the following code. Can anyone explain, in simple terms, how min(amt) sorts the results in asc order? I thought min() returns one value. Why does max(amt) give the exact same results? Sorting by min() gives the results I want, but trying to understand how it does it.</p>
  
  <pre><code>select (case when amt &gt; 200 then '&gt;200'
               when amt &gt; 100 then  '&gt;100'
            else '&gt;50'
          end)
  count(distinct orderno)
  from xyz
  where order_date between '...' and sysdate
  group by (case when amt &gt; 200 then '&gt;200'
               when amt &gt; 100 then  '&gt;100'
            else '&gt;50'
          end)
  order by min(amt)
  
  Result:
  &gt; 50
  &gt;100
  &gt;200
  </code></pre>