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,S.age,S.coins,S.power
FROM Wands AS W JOIN
(SELECT age,power,MIN(coins_needed) AS coins, Wands.code FROM Wands
JOIN Wands_Property ON Wands.code=Wands_Property.code
WHERE is_evil=0
GROUP BY code, age,power) AS S
ON W.code=S.code and W.coins_needed=S.coins
ORDER BY S.power DESC,S.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 →
My code:
SELECT W.id,S.age,S.coins,S.power FROM Wands AS W JOIN (SELECT age,power,MIN(coins_needed) AS coins, Wands.code FROM Wands JOIN Wands_Property ON Wands.code=Wands_Property.code WHERE is_evil=0 GROUP BY code, age,power) AS S ON W.code=S.code and W.coins_needed=S.coins ORDER BY S.power DESC,S.age DESC;