Ollivander's Inventory

  • + 1 comment

    with min_coin as ( select code, power, min(coins_needed) as coins_required from Wands group by code, power )

    Select w.id, wp.age, w.coins_needed, w.power from Wands w join Wands_property wp on w.code = wp.code join min_coin mc on w.code = mc.code and w.power = mc.power where wp.is_evil = 0 and w.coins_needed = mc.coins_required order by w.power desc, wp.age desc