Medium - Q7

mail@pastecode.io avatar
unknown
sql
2 years ago
333 B
3
Indexable
Never
select w.id, wp.age, w.coins_needed, w.power from wands w join Wands_Property wp on w.code = wp.code where wp.is_evil != 1 and w.coins_needed = (select min(coins_needed) from wands join wands_property on wands.code = wands_property.code where wands.power = w.power and wands_property.age = wp.age) order by w.power desc, wp.age desc;