title: Using distinct on a column and doing order by on another column gives an error
body: <p>I have a table:
   abc_test with columns n_num, k_str.</p>
  
  <p>This query doesnt work:</p>
  
  <pre><code>    select distinct(n_num) from abc_test order by(k_str)
  </code></pre>
  
  <p>But this one works:</p>
  
  <pre><code>    select n_num from abc_test order by(k_str)
  </code></pre>
  
  <p>How do DISTINCT and ORDER BY keywords work internally that output of both the queries is changed?</p>