SQL QuestSQL Interview Questions › Aggregation & Grouping

Title Social Survival Analysis

MediumFreeQuerying BasicsAggregation & GroupingConditional LogicString Functions

Classify passengers by social title using LIKE: 'Male' (name contains 'Mr.' or 'Master.'), 'Female' (contains 'Mrs.' or 'Miss.'), 'Other' (everything else). For each group show: title_group, count, avg_fare (2 dec), survival_rate (% survived, 1 dec). Only show groups with 5+ passengers. Order by survival_rate 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: Title-based survival rates revealing social hierarchy

Hint

Use CASE WHEN name LIKE '%Mr.%' OR name LIKE '%Master.%' THEN 'Male' WHEN name LIKE '%Mrs.%' OR name LIKE '%Miss.%' THEN 'Female' ELSE 'Other' END

Concepts

SELECT GROUP BY Aggregation HAVING CASE LIKE String Functions

Practise the topic: SQL practice questions · GROUP BY exercises · CASE WHEN practice · String function practice

In these company practice sets

Google · 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