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 w1.id,
w2.age,
w1.coins_needed,
w1.power
FROM Wands AS w1
JOIN Wands_Property AS w2
ON w1.code = w2.code
WHERE w2.is_evil = 0
AND w1.coins_needed = (
SELECT MIN(a.coins_needed)
FROM Wands AS a
JOIN Wands_Property AS b
ON a.code = b.code
WHERE a.power = w1.power
AND b.age = w2.age
)
ORDER BY w1.power DESC, w2.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 w1.id, w2.age, w1.coins_needed, w1.power FROM Wands AS w1 JOIN Wands_Property AS w2 ON w1.code = w2.code WHERE w2.is_evil = 0 AND w1.coins_needed = ( SELECT MIN(a.coins_needed) FROM Wands AS a JOIN Wands_Property AS b ON a.code = b.code WHERE a.power = w1.power AND b.age = w2.age ) ORDER BY w1.power DESC, w2.age DESC;