Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Set Difference Without Nesting

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

Your question is SQL Set Difference Without Nesting. 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

Write a query to list the rows present in the first table but not in the second table without using any nested query.

Use the provided tables and match rows by record_id. Return only records from the first table that have no matching record_id in the second table.

Output

  1. One row per unmatched record from first_table
  2. Columns: record_id, row_label, and status
  3. Order by record_id ascending

Schema

first_table
ColumnTypeDescription
record_idPKINTUnique identifier for the first-table row
row_labelVARCHAR(100)Descriptive label for the row
statusVARCHAR(20)Optional status value
second_table
ColumnTypeDescription
record_idPKINTUnique identifier for the second-table row
row_labelVARCHAR(100)Descriptive label for the row
statusVARCHAR(20)Optional status value
Tablesfirst_tablesecond_table
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results