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.
Because we are trying to find the cheapest wand of each power and age (thinhproee is approximating code with age here).
So the outer query returns a list of every wand, age, cost, and power, then we filter out the wands whose cost (of a particular power and age) are not the minimum cost (of a particular power and age).
We would get the same result if we used
JOIN (SELECT w.power, p.age, MIN(w.coins_needed)
FROM Wands w
JOIN Wands_property p on p.code = w.code
GROUP BY w.power, p.age) sub ON sub.power = w.power AND sub.age = p.age
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 →
Because we are trying to find the cheapest wand of each power and age (thinhproee is approximating code with age here).
So the outer query returns a list of every wand, age, cost, and power, then we filter out the wands whose cost (of a particular power and age) are not the minimum cost (of a particular power and age).
We would get the same result if we used JOIN (SELECT w.power, p.age, MIN(w.coins_needed) FROM Wands w JOIN Wands_property p on p.code = w.code GROUP BY w.power, p.age) sub ON sub.power = w.power AND sub.age = p.age