Ollivander's Inventory

  • + 0 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