Skip to content

Montgomery yards per carry, 2024

Level 1 · Challenge 4
Rookie

Prompt

Compute David Montgomery’s yards per carry across the 2024 regular season — total rushing yards divided by total carries. Round to two decimal places.

Expected output

A single row:

yards_per_carry
(decimal)
Hint

SUM(rushing_yards) / SUM(carries) is correct in principle, but integer-vs-real math will bite you. Cast one side to REAL or use ::numeric. ROUND(..., 2) for two decimals.

Solution
SELECT
ROUND(
SUM(rushing_yards)::numeric / NULLIF(SUM(carries), 0),
2
) AS yards_per_carry
FROM weekly_stats
WHERE player_display_name = 'David Montgomery'
AND season = 2024
AND season_type = 'REG';

NULLIF(SUM(carries), 0) prevents a divide-by-zero if the filter ever returns nothing. Habit worth forming early.