Mysql
 sql >> Base de données >  >> RDS >> Mysql

Obtenir le Top 3 de la table Mysql en fonction de la condition/valeur

Eh bien, vous pouvez essayer cet ensemble de requête :

(SELECT Name, PositionId, TScore FROM Soccerplayers WHERE PositionID = 1 ORDER BY TScore LIMIT 3)
UNION
(SELECT Name, PositionId, TScore FROM Soccerplayers WHERE PositionID = 2 ORDER BY TScore LIMIT 4)
UNION
(SELECT Name, PositionId, TScore FROM Soccerplayers WHERE PositionID = 3 ORDER BY TScore LIMIT 3)