Ollivander's Inventory

  • + 0 comments

    i always get this error and i don't know how to fix it "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 'cte as "

    these are the 2 queries i tried with cte as ( select a.id as id, b.age as age, a.coins_needed as coins_needed, a.power as power, rank() over (partition by age, power order by coins_needed) as rank1 from wands as a left join wands_property as b on a.code = b.code where b.is_evil = 0 ) select id, age, coins_needed, power from cte where rank1 = 1 order by power desc, age desc;

    \\\\\\\\\

    select id, age, power ,coins_needed from (select w.id, wp.age, w.power,w.coins_needed, Row_number()over(partition by w.power,wp.age order by w.coins_needed) as rn from wands as w inner join Wands_property as wp on w.code = wp.code and wp.is_evil = 0 order by w.power desc, wp.age desc) rr where rn =1 order by power desc, age desc ;