Medium 7

 avatar
Manishyadav514
mysql
2 years ago
374 B
1
Indexable
Never
SELECT id, age, powercode.coins, W.power 
FROM Wands W 
INNER JOIN (SELECT Code, Power, Min(coins_needed) as coins FROM Wands 
Group by Code, Power) powercode ON W.Code = powercode.Code 
AND W.Power = powercode.Power and powercode.coins = W.coins_needed  
INNER JOIN Wands_Property WiPo ON WiPo.Code = powercode.Code 
WHERE is_evil = 0 ORDER BY W.Power desc, Age desc;