title: How to do arithemtic operations with an alias in sqlite
body: <p>I want to calculate with an alias in sqlite (Example is modified from <a href="http://www.sqlitetutorial.net" rel="nofollow noreferrer">http://www.sqlitetutorial.net</a>):</p>
  
  <p>if i do it like this, i get the error message "no such column: tracks_count"</p>
  
  <pre><code>SELECT albumid,
         title,
         (
             SELECT count(trackid) 
               FROM tracks
              WHERE tracks.AlbumId = albums.AlbumId
         )
         tracks_count, tracks_count * album_nr
    FROM albums
   ORDER BY tracks_count DESC;
  </code></pre>
  
  <p>if i do it like this, i get zero for the mulitplication</p>
  
  <pre><code>SELECT albumid,
         title,
         (
             SELECT count(trackid) 
               FROM tracks
              WHERE tracks.AlbumId = albums.AlbumId
         )
         tracks_count, "tracks_count" * album_nr
    FROM albums
   ORDER BY tracks_count DESC;
  </code></pre>
  
  <p>Table data for the example:</p>
  
  <p>table albums</p>
  
  <p><a href="https://i.stack.imgur.com/wyMfF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wyMfF.png" alt="albums"></a></p>
  
  <p>table tracks</p>
  
  <p><a href="https://i.stack.imgur.com/cjDaa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cjDaa.png" alt="tracks"></a></p>