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 Defects Per Test Run
00:00
5 left

SQL Defects Per Test Run

EasySQL · PostgreSQL

Problem

Write an SQL query to join a test results table with a defects table and show the number of defects per test run.

Use the provided test_results and defects tables. Include test runs that have no matching defects.

Output

  1. One row per test run, with columns test_run_id and defect_count.
  2. Include each test run represented in test_results, including zero-defect runs.
  3. Order by test_run_id ascending.

Schema

test_results
ColumnTypeDescription
result_idPKINTUnique identifier for a test result
test_run_idINTIdentifier of the test run
test_nameVARCHAR(100)Name of the executed test
statusVARCHAR(20)Outcome of the test result
defects
ColumnTypeDescription
defect_idPKINTUnique identifier for a defect
test_result_idINTIdentifier of the test result associated with the defect
defect_codeVARCHAR(30)Reference code for the defect
severityVARCHAR(20)Defect severity classification
Tablestest_resultsdefects
Interviewer

Your question is SQL Defects Per Test Run. 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.