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
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
Get started
Most Recent Passing Test Per Module
00:00
5 left

Most Recent Passing Test Per Module

MediumSQL · PostgreSQL

Problem

Apex Systems QA engineers review automated test execution history across product modules. Write a PostgreSQL query that reports the most recent passing test for every module, including modules that have no passing test.

Requirements

  1. Return every module from modules, even when it has no test run or no passing test.
  2. Consider only rows where test_runs.status = 'PASS'.
  3. Select the latest passing run by executed_at. If multiple passing runs have the same timestamp, choose the row with the greatest test_run_id.
  4. Return the module ID, module name, selected test run ID, and execution timestamp, ordered by module ID.

Schema

modules
ColumnTypeDescription
module_idPKINTEGERUnique identifier for a product module
module_nameVARCHAR(100)Human-readable module name
test_runs
ColumnTypeDescription
test_run_idPKINTEGERUnique identifier for a test execution
module_idINTEGERModule tested by the run
statusVARCHAR(20)Test outcome
executed_atTIMESTAMPCompletion timestamp of the test run
Tablesmodulestest_runs
Interviewer

Your question is Most Recent Passing Test Per Module. Start with the requirements and the two 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.