WITH
	HOME AS (
		SELECT
			HOME_TEAM TEAM,
			SUM(
				CASE
					WHEN HOME_GOALS < 0 THEN 0
					ELSE HOME_GOALS
				END
			) GOALS
		FROM
			PL_MATCHES
		GROUP BY
			HOME_TEAM
	),
	AWAY AS (
		SELECT
			AWAY_TEAM TEAM,
			SUM(
				CASE
					WHEN AWAY_GOALS < 0 THEN 0
					ELSE AWAY_GOALS
				END
			) GOALS
		FROM
			PL_MATCHES
		GROUP BY	
			TEAM
	)
SELECT
	COALESCE(HOME.TEAM, AWAY.TEAM) AS TEAM,
	COALESCE(HOME.GOALS, 0) + COALESCE(AWAY.GOALS, 0) AS GOALS
FROM
	HOME
	FULL OUTER JOIN AWAY ON HOME.TEAM = AWAY.TEAM
ORDER BY
	GOALS DESC;