Ollivander's Inventory

  • + 0 comments

    /* display id, age, coins_needed, power where

    Hermione wants to see only the minimum price for every Power/Age combination in the results which is non evil

    so for each power & age combination find min_coins required and then sort

    For MySql -

    */

    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 and w.coins_needed = (select min(w1.coins_needed) from wands w1 join wands_property p1 on w1.code=p1.code where p.is_evil=0 and w.power=w1.power and p.code=p1.code) order by w.power desc,p.age desc