SQL QuestSQL Interview Questions › String Functions

Passenger Family Survival Analysis

HardProQuerying BasicsString FunctionsAggregation & Grouping

Extract each passenger's last name (before the comma) and group potential family members. For last names shared by 2 or more passengers, show: last_name, family_size, survivors, survival_rate (1 dec). Sort by family_size descending. This reveals whether families survived together.

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: Braund | 2 | 1 | 50.0

Hint

This is a Pro challenge — the hint, the step-by-step tutor and the reference solution open in the app.

Concepts

SELECT String Functions GROUP BY HAVING Aggregation

Practise the topic: SQL practice questions · String function practice · GROUP BY exercises · Advanced SQL interview questions

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

Department Roster with GROUP_CONCATMedium · FreeTitle Social Survival AnalysisMedium · FreeEmail Provider Customer AnalysisMedium · FreeEmail Username Extract (SUBSTR + INSTR)Medium · FreeTrust and Savings BanksMedium · FreeLLC vs Individual BuyersMedium · 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