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.
SELECT c.id, a.age, a.min_coins_needed, a.power
FROM (
SELECT a.code, a.age, MIN(b.coins_needed) as min_coins_needed, b.power
FROM Wands_property a
JOIN wands b
on a.code = b.code
where a.is_evil = 0
group by a.code, a.age, b.power
)a
JOIN wands c
on a.code = c.code
and a.power = c.power
and a.min_coins_needed = c.coins_needed
ORDER BY a.power desc, a.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 →
SELECT c.id, a.age, a.min_coins_needed, a.power FROM ( SELECT a.code, a.age, MIN(b.coins_needed) as min_coins_needed, b.power FROM Wands_property a JOIN wands b on a.code = b.code where a.is_evil = 0 group by a.code, a.age, b.power )a JOIN wands c on a.code = c.code and a.power = c.power and a.min_coins_needed = c.coins_needed ORDER BY a.power desc, a.age desc