Assignment Query Desk
satisfies the subquery requirement and returns the top scorer for every season.
Query brief
Top scorer in each season using a subquery.
capture the result grid in phpMyAdmin after running the query.
SELECT
season_scores.season_label,
season_scores.player_name,
season_scores.team_name,
season_scores.ppg
FROM (
SELECT
s.season_id,
s.season_label,
p.person_id,
CONCAT(p.first_name, ' ', p.last_name) AS player_name,
t.team_name,
ROUND(AVG(pgs.points), 1) AS ppg
FROM player_game_stats pgs
INNER JOIN games g ON g.game_id = pgs.game_id
INNER JOIN seasons s ON s.season_id = g.season_id
INNER JOIN people p ON p.person_id = pgs.person_id
INNER JOIN roster_assignments ra ON ra.person_id = pgs.person_id AND ra.season_id = s.season_id
INNER JOIN teams t ON t.team_id = ra.team_id
GROUP BY s.season_id, s.season_label, p.person_id, p.first_name, p.last_name, t.team_name
) AS season_scores
INNER JOIN (
SELECT
g.season_id,
MAX(player_ppg.ppg) AS max_ppg
FROM (
SELECT g.season_id, pgs.person_id, ROUND(AVG(pgs.points), 1) AS ppg
FROM player_game_stats pgs
INNER JOIN games g ON g.game_id = pgs.game_id
GROUP BY g.season_id, pgs.person_id
) AS player_ppg
INNER JOIN games g ON g.season_id = player_ppg.season_id
GROUP BY g.season_id
) AS season_max
ON season_max.season_id = season_scores.season_id
AND season_max.max_ppg = season_scores.ppg
ORDER BY season_scores.season_id DESC, season_scores.player_name ASC;
Live result
| Season Label | Player Name | Team Name | Ppg |
|---|---|---|---|
| 2025-26 | Nicolas Laprovittola | FC Barcelona | 23.3 |
| 2024-25 | Scottie Wilbekin | Fenerbahce Beko Istanbul | 23.1 |
| 2023-24 | Scottie Wilbekin | Fenerbahce Beko Istanbul | 23.3 |
| 2022-23 | Nigel Williams-Goss | Olympiacos Piraeus | 24.6 |
| 2021-22 | Nicolas Laprovittola | FC Barcelona | 24.1 |
| 2020-21 | Scottie Wilbekin | Fenerbahce Beko Istanbul | 23.1 |
| 2019-20 | Nigel Williams-Goss | Olympiacos Piraeus | 24.3 |
| 2018-19 | Nicolas Laprovittola | FC Barcelona | 23.4 |
| 2017-18 | Scottie Wilbekin | Fenerbahce Beko Istanbul | 23.4 |
| 2016-17 | Jordan Loyd | AS Monaco | 23.7 |