Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Start free
Outer Join SQL
00:00
5 left

Outer Join SQL

EasySQL · PostgreSQL

Problem

Write an outer join SQL query for this scenario.

Use the provided source_a and source_b tables. Return every record identifier appearing in either table, including identifiers without a matching row.

Output

  1. One row per identifier appearing in either table
  2. Columns: record_id, source_a_value, and source_b_value
  3. Use NULL when a source has no matching record
  4. Order by record_id ascending

Schema

source_a
ColumnTypeDescription
record_idPKINTUnique record identifier
record_valueVARCHAR(100)Value associated with the record in source A
source_b
ColumnTypeDescription
record_idPKINTUnique record identifier
record_valueVARCHAR(100)Value associated with the record in source B
Tablessource_asource_b
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

Sign up free to run or submit. Log in
CodePostgreSQL
Sign up free to run your code. Your draft is saved.Run with a free accountLog inLn 1
Run your query to see results here.