Untitled
unknown
sql
4 years ago
511 B
6
Indexable
SELECT Wands.id, Wands_Property.age, Wands.coins_needed, Wands.power FROM Wands /* inner join on the two tables to get the age and id */ INNER JOIN Wands_Property ON Wands.code = Wands_Property.code AND Wands.coins_needed = ( SELECT MIN(coins_needed) FROM Wands AS w INNER JOIN Wands_Property AS wp ON w.code = wp.code WHERE Wands.power = w.power AND Wands_Property.age = wp.age ) /* using WHERE to fetch non-evil wands */ WHERE Wands_Property.is_evil = 0 /* sort the result by power and age in descending order
Editor is loading...