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.
The following worked for me:
SELECT W.id, WP.age, W.coins_needed, W.power FROM Wands W INNER JOIN Wands_Property WP ON W.code = WP.code WHERE WP.is_evil != 1 AND W.coins_needed = (SELECT MIN(W2.coins_needed) FROM Wands W2 INNER JOIN Wands_Property WP2 ON W2.code = WP2.code WHERE WP2.age = WP.age AND W2.power = W.power) ORDER BY W.power DESC, WP.age DESC
PLEASE UPVOTE!!!
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 →
The following worked for me: SELECT W.id, WP.age, W.coins_needed, W.power FROM Wands W INNER JOIN Wands_Property WP ON W.code = WP.code WHERE WP.is_evil != 1 AND W.coins_needed = (SELECT MIN(W2.coins_needed) FROM Wands W2 INNER JOIN Wands_Property WP2 ON W2.code = WP2.code WHERE WP2.age = WP.age AND W2.power = W.power) ORDER BY W.power DESC, WP.age DESC
PLEASE UPVOTE!!!