Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
SQL Expected vs Actual Comparison
00:00
5 left

SQL Expected vs Actual Comparison

HardSQL · PostgreSQL

Problem

The 6sense QA team validates platform behavior by storing expected API or UI results separately from results observed during automated test runs. Write a PostgreSQL query that compares the expected and actual result rows for every 6sense test case.

Requirements

  1. Return every test case, including cases with no recorded result rows.
  2. Report expected row count, actual row count, mismatched row count, missing expected rows, and unexpected actual rows.
  3. Mark each case as PASS, FAIL, or NOT_RUN. Treat two NULL result values as equal.
  4. Order the output by test_case_id ascending.

Schema

test_cases
ColumnTypeDescription
test_case_idPKINTUnique test case identifier
test_nameVARCHAR(150)Name of the QA test case
expected_results
ColumnTypeDescription
test_case_idINTReferenced test case
result_keyPKVARCHAR(80)Assertion or response field name
expected_valueVARCHAR(255)Value expected by the test
actual_results
ColumnTypeDescription
test_case_idINTReferenced test case
result_keyPKVARCHAR(80)Observed assertion or response field name
actual_valueVARCHAR(255)Value observed during test execution
Tablestest_casesexpected_resultsactual_results
Interviewer

Your question is SQL Expected vs Actual Comparison. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.