Ollivander's Inventory

  • + 0 comments

    SELECT
    w.id,
    wpro.age, 
    w.coins_needed,
    w.power
    FROM Wands as w
    JOIN Wands_Property as wpro
    ON w.code = wpro.code
    WHERE
    wpro.is_evil = 0
    AND
    w.coins_needed = (
    SELECT Min(w2.coins_needed)
    FROM Wands as w2
    JOIN Wands_Property as wpro2
    ON w2.code = wpro2.code
    WHERE wpro2.is_evil = 0 AND wpro.age = wpro2.age AND w.power = w2.power
    )
    ORDER BY
    w.power DESC,
    wpro.age DESC;