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, p.age, w.coins_needed, w.power
FROM wands w
JOIN wands_property p ON w.code = p.code
WHERE p.is_evil = 0
-- minimum coins needed to buy that wand with same power and age
AND w.coins_needed = (SELECT MIN(coins_needed)
FROM wands w1
JOIN wands_property p1 ON w1.code = p1.code
WHERE w1.power = w.power
AND p1.age = p.age)
ORDER BY w.power DESC, p.age DESC
Ollivander's Inventory
You are viewing a single comment's thread. Return to all comments →
SELECT w.id, p.age, w.coins_needed, w.power FROM wands w JOIN wands_property p ON w.code = p.code WHERE p.is_evil = 0 -- minimum coins needed to buy that wand with same power and age AND w.coins_needed = (SELECT MIN(coins_needed) FROM wands w1 JOIN wands_property p1 ON w1.code = p1.code WHERE w1.power = w.power AND p1.age = p.age) ORDER BY w.power DESC, p.age DESC