Back to questions

SQL Filtering Practice Exercise #1 SQL Interview Question

SQL Filtering Practice Exercise #1

SQL Interview Question

You have a table of 1000 customer records from a small-business based in Australia.

Find all customers who are between the ages of 18 and 22 (inclusive), live in either Victoria, Tasmania, Queensland, their gender isn't "n/a", and their name starts with either 'A' or 'B'.

Schema:

Column NameType
customer_idinteger
customer_namestring
genderstring
ageinteger
zip_codeinteger
citystring
statestring

Sample Input:

customer_idcustomer_namegenderagezip_codecitystate
1Ignace WhillockMale305464JohnstonhavenNorthern Territory
2Gray EskrickFemale698223New ZacharyfortSouth Australia
3Ellswerth LaurentMale595661AliburghAustralian Capital Territory
.......................

Example Output

customer_idcustomer_namegenderagezip_codecitystate
123Aidan GoselingFemale221149JordanboroughTasmania
402Adeline PerringtonFemale221712West CooperTasmania
692Bertrando MelonbyMale204058LaraviewTasmania
900Audrie FrottonFemale229455East EmilyTasmania

Difficulty

Easy

Input

Output