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
Query Failed Executions and Validation Checks
00:00
5 left

Query Failed Executions and Validation Checks

MediumSQL · PostgreSQL

Problem

What are your strategies for debugging SQL queries?

Describe a systematic, PostgreSQL-focused approach using the provided execution and validation records. Write a query that surfaces executions requiring investigation, including failed executions and successful executions with failed validation checks.

Output

  1. One row per execution requiring investigation, with execution_id, query_name, status, error_message, and failed_check_count.
  2. Include executions with a non-success status or at least one failed validation check.
  3. Order by failed_check_count descending, execution timestamp descending, and execution_id ascending.

Schema

query_executions
ColumnTypeDescription
execution_idPKINTUnique query execution identifier
query_nameVARCHAR(100)Name of the executed SQL query
executed_atTIMESTAMPTimestamp when execution started
statusVARCHAR(20)Execution status
returned_rowsINTNumber of rows returned by the query
error_messageVARCHAR(255)Database error message when execution fails
query_validation_checks
ColumnTypeDescription
check_idPKINTUnique validation check identifier
execution_idINTReferenced query execution
check_nameVARCHAR(100)Name of the validation check
statusVARCHAR(20)Validation result status
observed_valueDECIMAL(12,2)Value observed by the check
expected_valueDECIMAL(12,2)Expected value for the check
notesVARCHAR(255)Additional validation details
Tablesquery_executionsquery_validation_checks
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

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.