title: SQL syntax error on Hackerrank challenge - Ollivander's Inventory
body: <p>I'm working throught the challenge detailed here:
  <a href="https://www.hackerrank.com/challenges/harry-potter-and-wands" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/harry-potter-and-wands</a></p>
  
  <p>and have come up with this solution but I'm getting a syntax error message instead or the results I expect. My code:</p>
  
  <pre><code>With
    m As (Select
    w.power,
    wp.age,
    Min(w.coins_needed) As min_coins
  From
    wands w Join
    wands_property wp
      On wp.code = w.code
  Where
    wp.is_evil = 0
  Group By
    w.power, wp.age)
  Select
  w.id,
  wp.age,
  w.coins_needed,
  w.power
  From
  wands w Join
  wands_property wp
  On wp.code = w.code
  Join m
  On m.power = w.power And m.age = wp.age And m.min_coins =
  w.coins_needed
  Where
  wp.is_evil = 0
  Order By
  w.power Desc,
  wp.age Desc,
  w.coins_needed Desc
  </code></pre>
  
  <p>The error message from hackerrank:</p>
  
  <pre><code>ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm As (Select
    w.power,
    wp.age,
    Min(w.coins_needed) As min_coins' at line 2
  </code></pre>
  
  <p>I don't see anything wrong. What am I missing?</p>