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

Query Walkthrough

MediumSQL & Data Manipulation00:00
Practice interviewer
In session
5 left
00:00

Your question is Query Walkthrough. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

A KPMG engagement team is testing for premature revenue recognition: contracts where the client's ledger recorded revenue before the contract's service period had even started, which is a classic audit red flag. You are given the schema below and asked to write the query yourself, not shown someone else's.

CREATE TABLE contracts (
    contract_id INT PRIMARY KEY,
    client_id INT,
    service_start_date DATE,
    service_end_date DATE,
    contract_value NUMERIC(14,2)
);

CREATE TABLE revenue_entries (
    entry_id BIGINT PRIMARY KEY,
    contract_id INT REFERENCES contracts(contract_id),
    recognized_date DATE,
    recognized_amount NUMERIC(14,2)
);

-- a contract can have zero, one, or many revenue_entries rows
-- recognized_date and service_start_date can both be NULL for a small number of
-- legacy contracts migrated from a prior system

Write a query that flags every revenue_entries row recognized before its contract's service_start_date, showing contract_id, client_id, recognized_date, service_start_date, and the amount recognized early. Then describe, in your own words, how you would validate that your query is correct before handing the result to the engagement partner: what edge cases would you test, and how would you check each one by hand.