title: How to order by calculated column in knexjs
body: <p>I'm trying to add a calculated/computed/virtual column to a query by doing the following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>knex.select(knex.raw('DATEDIFF("2018-04-15", STR_TO_DATE(birthdate, "%d/%m/%Y")) / 365.25 as age'))
  .from('user')
  .orderBy('age', 'desc');</code></pre>
  </div>
  </div>
  </p>
  
  <p>However, I end up with the following error:</p>
  
  <pre><code>BadRequest: select count(`user`.`id`) as `total` from `user` order by `id` desc, `age` desc - Unknown column 'age' in 'order clause'
  </code></pre>
  
  <p>I think it may have something with how I'm structuring my query, but it doesn't seem to recognize the calculated column as one that can be ordered.</p>