Let’s say I have a simple table with NBA players:
id,player,mp,ppg (mp – matches played, ppg – points per game).
I need a query that gets all the guys but split the result into two parts:
- players who played in more or equal 30 games ordered by PPG desc,
- players who played less than 30 games ordered by PPG desc
So desirable output would be (example):
n. player mp ppg
1. player1 82 32.5
2. player2 56 32.1
3. player3 82 29.7
4. player4 80 27.6
…
70. player70 75 1.5 (lowest in the 30+ games group)
71. player71 29 35.7 (highest in the less than 30 games group)
72. player72 19 31.3
…
Group 1) comes first (is more important) so even if PPG in group 2) is higher than the best one in group 1) it goes down after the worst PPG in the group where players have more than 30 games played.
Is there a way to do that in just one query? I’m using mySQL. Thanks!
1 Answer