Ollivander's Inventory

  • + 0 comments

    With Cte as (select WP.age as Cte_Age, min(W.coins_needed) as Cte_Coins,W.power as Cte_Power from Wands W left join Wands_Property WP on W.code = WP.code where WP.is_evil = 0 group by WP.age, W.power ) select max(A.id) ,Cte_Age,Cte_Coins,Cte_Power from Cte inner join Wands A on A.coins_needed = Cte_Coins and A.power = Cte_Power inner join Wands_Property B on B.Age = Cte_Age where B.is_evil = 0 group by Cte_age,Cte_Coins, Cte_Power order by Cte_Power desc, Cte_Age desc