We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ollivander's Inventory
You are viewing a single comment's thread. Return to all 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