Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.