Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Audit Inherited Spreadsheet Exceptions

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Audit Inherited Spreadsheet Exceptions. Start with the requirements and the two tables on the right.

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.

Problem

You inherited a spreadsheet and need to audit it for data quality issues before using it in analysis. Write a PostgreSQL query that flags each record as matched, missing_in_source, duplicate_in_sheet, or invalid_amount by comparing the spreadsheet rows to the source system and checking for duplicate sheet entries and non-positive amounts.

Schema

source_transactions
ColumnTypeDescription
source_txn_idPKINTPrimary key in the source system
account_codeVARCHAR(20)Ledger account code
txn_dateDATETransaction date
amountDECIMAL(12,2)Source amount
spreadsheet_rows
ColumnTypeDescription
sheet_row_idPKINTPrimary key for the inherited spreadsheet row
source_txn_idINTSource transaction id copied into the sheet
account_codeVARCHAR(20)Account code in the sheet
txn_dateDATETransaction date in the sheet
amountDECIMAL(12,2)Amount entered in the sheet
Tablessource_transactionsspreadsheet_rows
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results