title: Where to put WHERE in mysql query
body: <p>I cannot find where I can put my WHERE clause in my query. It seems like I tried every possible position but nothing is working.</p>
  
  <pre><code>SELECT res
  FROM (
  SELECT `date`,SUM(DISTRIBUTED_AMOUNT / EXCHANGE_RATE) AS res
  FROM royalties 
  GROUP BY `date`
  ORDER BY `date` DESC LIMIT 12
  ) a
  ORDER BY `date` ASC
  WHERE `BUNDLE_ARTIST` = '" . $artist_name . "'
  </code></pre>