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 min_coin as (
select code, power, min(coins_needed) as coins_required from Wands
group by code, power
)
Select w.id, wp.age, w.coins_needed, w.power from Wands w
join Wands_property wp on w.code = wp.code
join min_coin mc on w.code = mc.code and w.power = mc.power
where wp.is_evil = 0 and w.coins_needed = mc.coins_required
order by w.power desc, wp.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 min_coin as ( select code, power, min(coins_needed) as coins_required from Wands group by code, power )
Select w.id, wp.age, w.coins_needed, w.power from Wands w join Wands_property wp on w.code = wp.code join min_coin mc on w.code = mc.code and w.power = mc.power where wp.is_evil = 0 and w.coins_needed = mc.coins_required order by w.power desc, wp.age desc