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
w.id,
wp.age,
w.coins_needed,
w.power
FROM
wands AS w
JOIN
wands_property AS wp
ON
w.code = wp.code
WHERE
wp.is_evil = 0
AND w.coins_needed = (
SELECT MIN(w2.coins_needed)
FROM wands AS w2
JOIN wands_property AS wp2
ON w2.code = wp2.code
WHERE wp2.is_evil = 0
AND wp.age = wp2.age
AND w.power = w2.power
)
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 →
SELECT w.id, wp.age, w.coins_needed, w.power FROM wands AS w JOIN wands_property AS wp ON w.code = wp.code WHERE wp.is_evil = 0 AND w.coins_needed = ( SELECT MIN(w2.coins_needed) FROM wands AS w2 JOIN wands_property AS wp2 ON w2.code = wp2.code WHERE wp2.is_evil = 0 AND wp.age = wp2.age AND w.power = w2.power ) ORDER BY w.power DESC, wp.age DESC;