SQL QuestSQL Interview Questions › Aggregation & Grouping

Senior Passengers by Port

MediumFreeQuerying BasicsAggregation & GroupingNULL Handling

A maritime historian is studying elderly travelers. For each embarkation port, count how many passengers were aged 60 or older. Exclude passengers with a NULL age. Show embarked and senior_count. Sort by senior_count descending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

passengers

passenger_idsurvivedpclassnamesexagesibspparchfareembarked
103Braund, Mr. Owen Harrismale22107.25S
211Cumings, Mrs. John Bradleyfemale381071.28C
313Heikkinen, Miss. Lainafemale26007.93S

Expected output: S | 12, C | 7, Q | 2

Hint

WHERE age >= 60 AND age IS NOT NULL filters out unknowns and juniors. GROUP BY embarked collapses per port. COUNT(*) gives the headcount per group.

Concepts

SELECT WHERE GROUP BY Aggregation NULL Handling

Practise the topic: SQL practice questions · GROUP BY exercises · NULL handling practice

In these company practice sets

Snowflake

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Class Survival BreakdownMedium · FreeDepartment Roster with GROUP_CONCATMedium · FreeMovie Rating Tier BreakdownMedium · FreeFull Survival Dashboard by ClassMedium · FreeGenre Financial ReportMedium · FreeDepartment Compensation ReportMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test