Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Report With Missing Addresses

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Report With Missing Addresses. Start with the requirements and the two tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

PlayStation QA needs a profile coverage report for PlayStation Network accounts. Write a PostgreSQL query that returns every person, whether or not a matching address exists.

Requirements

  1. Return FirstName, LastName, City, and State for every row in person.
  2. Preserve people without an address, showing NULL for missing address fields.
  3. Order the report by person_id ascending so the output is deterministic.

Use a join that does not accidentally exclude profiles lacking address records.

Schema

person
ColumnTypeDescription
person_idPKINTEGERUnique person identifier
first_nameVARCHAR(50)Person's first name
last_nameVARCHAR(50)Person's last name
address
ColumnTypeDescription
address_idPKINTEGERUnique address identifier
person_idINTEGERPerson associated with the address
cityVARCHAR(100)City in the profile address
stateVARCHAR(100)State, province, or region
Tablespersonaddress
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results