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
SQL Data Retrieval and Validation
00:00
5 left

SQL Data Retrieval and Validation

MediumSQL · PostgreSQL

Problem

Can you write SQL queries to retrieve specific data from a database and validate the results?

Use the validation_results table. Retrieve failed validations with at least one recorded defect. Exclude rows with a missing defect count and return the results in reverse execution order.

Output

  1. One row per matching validation, with validation_id, test_name, executed_on, and defect_count
  2. Include only failed validations with defect_count greater than zero
  3. Order by executed_on descending, then validation_id ascending

Schema

validation_results
ColumnTypeDescription
validation_idPKINTUnique validation result identifier
test_nameVARCHAR(100)Name of the validation test
result_statusVARCHAR(20)Validation outcome
severityVARCHAR(20)Severity assigned to the validation result
executed_onDATEDate when the validation ran
defect_countINTNumber of defects identified by the validation
Tablesvalidation_results
Interviewer

Your question is SQL Data Retrieval and Validation. Start with the requirements and the one table 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.