Practice · Art & Cinema · Medium

Average lifespan of the greats

For the cultural figures who have died (death_year is not NULL), return their average lifespan in years as avg_lifespan, rounded to 1 decimal.

Runs in your browser. No signup needed.

What you are given

Use cultural_figures. Lifespan = death_year − birth_year; only include rows where death_year IS NOT NULL.

Starting point

SELECT ROUND(AVG(death_year - birth_year), 1) AS avg_lifespan
FROM cultural_figures
WHERE death_year IS NOT NULL;

The reference solution is checked automatically when you run your query on the practice page — results are compared row by row.

Did you know

If you forget the IS NOT NULL filter, SQL skips the NULLs inside AVG automatically — but death_year − birth_year would still be NULL for the living, so filtering makes your intent explicit. (SQLite docs)

More Art & Cinema challenges

Open it in the playground →