SQL QuestSQL Interview Questions › Querying Basics

Passengers Without Mr. or Mrs. (NOT LIKE)

EasyFreeQuerying Basics

A genealogy team is curating profiles for passengers without the standard Mr./Mrs. honorifics — typically children, professionals with a Dr./Master./Miss. title, or unmarked names.

Find passengers whose name does not contain 'Mr.' AND does not contain 'Mrs.'. Show name, sex, age. Order by name. Limit to 20 rows.

NOT LIKE '%Mr.%' excludes any name with Mr. anywhere in it. Combining two NOT LIKE conditions with AND is how you stack exclusion filters. (Note: this will also exclude Mr. substring matches inside other words — fine for this dataset, but worth knowing.)

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: Only 'Bonnell, Miss. Elizabeth' appears

Hint

WHERE name NOT LIKE '%Mr.%' AND name NOT LIKE '%Mrs.%'. The percent signs are wildcards meaning "anything before or after". The period inside the pattern is a literal period.

Concepts

SELECT WHERE NOT LIKE

Practise the topic: SQL practice questions

Related questions

Your First QueryEasy · FreePick Your ColumnsEasy · FreeFilter with WHEREEasy · FreeComparison OperatorsEasy · FreeMultiple Conditions (AND / OR)Easy · FreeThe IN OperatorEasy · 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