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 cta.id,cta.age,cta.coins_needed,cta.power
FROM
(SELECT a.id,a.coins_needed,a.power,b.age
FROM Wands a
LEFT JOIN Wands_Property b
ON a.code = b.code
WHERE b.is_evil = 0) cta
WHERE (cta.age,cta.coins_needed,cta.power) IN
(SELECT b.age,MIN(a.coins_needed),a.power
FROM Wands a
LEFT JOIN Wands_Property b
ON a.code = b.code
WHERE b.is_evil = 0
GROUP BY b.age,a.power)
ORDER BY cta.power DESC,cta.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 →
For MySql -
SELECT cta.id,cta.age,cta.coins_needed,cta.power FROM (SELECT a.id,a.coins_needed,a.power,b.age FROM Wands a LEFT JOIN Wands_Property b ON a.code = b.code WHERE b.is_evil = 0) cta WHERE (cta.age,cta.coins_needed,cta.power) IN (SELECT b.age,MIN(a.coins_needed),a.power FROM Wands a LEFT JOIN Wands_Property b ON a.code = b.code WHERE b.is_evil = 0 GROUP BY b.age,a.power) ORDER BY cta.power DESC,cta.age DESC