The Best Of Baseball Awards: unexpected query result

Hi everyone,

In “The Best of Baseball award” project within the " Design Databases With PostgreSQL" path,
(https://www.codecademy.com/paths/design-databases-with-postgresql/tracks/what-can-i-do-with-a-database/modules/querying-baseball-data-off-platform-project/informationals/off-platform-project-baseball-through-the-years)
can anyone tell me what is wrong with this query?

SELECT
     people.namefirst,
     people.namelast,
     ROUND(AVG(people.weight), 2) AS average_weight,
     teams.name, 
     batting.yearid 
 FROM people 
 INNER JOIN batting 
     ON people.playerid = batting.playerid
 INNER JOIN teams
     ON batting.team_id = teams.id
 GROUP BY 
     teams.name,
     batting.yearid,
     people.namelast,
     people.namefirst
 ORDER BY 3 DESC;

It executes without errors but the average_weight column by which I want to ORDER BY is empty.
It works just fine if I instead ORDER BY any other column.
What tiny detail am I missing here?
Thanks

It seems I misinterpreted the question.
It was asked to query for the team with the average heaviest players, thus the first and last name of the player are not required.
This way the query gives the expected result, hopefully.
I am leaving the rest of my solution below in case someone stumbles on this post.
It differs from the proposed solution in few lines. I will investigate if anything is wrong with my pitch.

-- TASK 1: Heaviest Hitters

SELECT 
    teams.name,
    ROUND(AVG(people.weight), 2) AS average_weight,
    batting.yearid
FROM teams 
INNER JOIN batting
    ON teams.id = batting.team_id
INNER JOIN people 
    ON batting.playerid = people.playerid
GROUP BY
    batting.yearid,
    teams.name
ORDER BY 2 DESC;

-- TASK 2: Shortest Sluggers

SELECT 
    teams.name,
    ROUND(AVG(people.height)) AS average_height,
    batting.yearid
FROM teams 
INNER JOIN batting
    ON teams.id = batting.team_id
INNER JOIN people 
    ON batting.playerid = people.playerid
GROUP BY
    batting.yearid,
    teams.name
ORDER BY 2 ASC;

-- TASK 3

SELECT
    teams.teamid,
    salaries.yearid,
    SUM(salaries.salary) AS total_salary
FROM teams
INNER JOIN salaries
    ON salaries.teamid = teams.teamid
    AND 
GROUP BY
    salaries.yearid,
    teams.teamid
ORDER BY 3 ASC;

-- TASK 4: Most Bang For Their Buck In 2010

SELECT
    teams.teamid,
    salaries.yearid,
    ROUND(CAST(SUM(salaries.salary) / teams.w AS DECIMAL), 2) AS cost_per_win
FROM teams
INNER JOIN salaries
    ON salaries.teamid = teams.teamid
GROUP BY
    salaries.yearid,
    teams.teamid,
    teams.w
HAVING salaries.yearid = 2010
ORDER BY 3 ASC;

-- TASK 5: Priciest Starter

SELECT 
    people.namefirst,
    people.namelast,
    
    pitching.yearid,
    pitching.gs,
    
    ROUND(salaries.salary / pitching.gs) AS money_per_game
FROM people
INNER JOIN pitching
    ON people.playerid = pitching.playerid
INNER JOIN salaries
    ON salaries.teamid = pitching.teamid
--WHERE pitching.gs > 10
GROUP BY
    pitching.yearid,
    salaries.salary,
    pitching.gs,
    people.namefirst,
    people.namelast
HAVING pitching.gs > 10
ORDER BY 5 DESC;
2 Likes