SELECT
SUM(salary),
teams.name,
salaries.yearid
FROM salaries
LEFT JOIN teams
ON teams.teamid = salaries.teamid
AND teams.yearid = salaries.yearid
GROUP BY
teams.name,
salaries.yearid
ORDER BY
SUM(salary)
DESC;
Hey guys, noob question. Why do I have to left join on both team id and year id? Wouldn’t teamid already return matching columns. I know I have to because the result is different when I only run one, but I just want to see what I’m missing…