Untitled

 avatar
user_1196610317
mysql
4 years ago
385 B
5
Indexable
SELECT w1.id,g.age,g.coins,g.power FROM Wands w1 
JOIN Wands_Property p1 ON w1.CODE=p1.CODE
RIGHT JOIN  
(SELECT p.age, MIN(w.coins_needed) coins,w.power FROM Wands w
JOIN Wands_Property p ON w.CODE=p.CODE
WHERE p.is_evil=0 
GROUP by p.age,w.power
ORDER by w.power DESC, p.age DESC) g 
ON w1.power=g.power AND w1.coins_needed=g.coins AND p1.age=g.age
ORDER BY g.power DESC, g.age descs
Editor is loading...