Skip to content

Sam LaPorta vs NFC North tight ends, 2024

Level 2 · Challenge 8
All-Pro

Prompt

Return two rows:

  1. Sam LaPorta’s 2024 regular-season totals.
  2. The combined totals of every other NFC North tight end in 2024 — every GB, MIN, and CHI player with position_group = 'TE', aggregated into a single row labeled NFC North TEs (ex-DET).

Both rows should have the same columns: label, games, catches, yards, TDs.

Expected output

labelgamescatchesyardstds
Sam LaPorta
NFC North TEs (ex-DET)
Hint

Two queries UNION ALL’d together. The first selects literal 'Sam LaPorta' as the label; the second selects literal 'NFC North TEs (ex-DET)'. Both queries aggregate from weekly_stats with different WHERE filters.

Solution
SELECT
'Sam LaPorta' AS label,
COUNT(*) AS games,
SUM(receptions) AS catches,
SUM(receiving_yards) AS yards,
SUM(receiving_tds) AS tds
FROM weekly_stats
WHERE player_display_name = 'Sam LaPorta'
AND season = 2024
AND season_type = 'REG'
AND targets > 0
UNION ALL
SELECT
'NFC North TEs (ex-DET)' AS label,
COUNT(*) AS games,
SUM(receptions) AS catches,
SUM(receiving_yards) AS yards,
SUM(receiving_tds) AS tds
FROM weekly_stats
WHERE recent_team IN ('GB', 'MIN', 'CHI')
AND position_group = 'TE'
AND season = 2024
AND season_type = 'REG'
AND targets > 0;

UNION ALL stacks rows. UNION (without ALL) deduplicates, which you don’t want here. Column names come from the first query; the second query must match column count and types.