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 id, age, coins_needed, power
FROM (
SELECT id, age, coins_needed, power, ROW_NUMBER() OVER(PARTITION BY age, power ORDER BY coins_needed) rk
FROM Wands w
JOIN Wands_Property wp
ON w.code=wp.code
WHERE is_evil=0
)
WHERE rk=1
ORDER BY power DESC, 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 id, age, coins_needed, power FROM ( SELECT id, age, coins_needed, power, ROW_NUMBER() OVER(PARTITION BY age, power ORDER BY coins_needed) rk FROM Wands w JOIN Wands_Property wp ON w.code=wp.code WHERE is_evil=0 ) WHERE rk=1 ORDER BY power DESC, age DESC ;