Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Detect Recurring Expense Recording Issues

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

Your question is Detect Recurring Expense Recording Issues. Start with the requirements and the three 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 are given expense transactions, category metadata, and recording rules. Your task is to identify expense categories that show a recurring recording issue in the last 90 days: categories with at least 3 invalid expenses and an invalid rate above 25%. Return the category name, total expense count, invalid expense count, and invalid rate, sorted by the highest invalid rate.

Schema

expense_categories
ColumnTypeDescription
category_idPKINTPrimary key for the expense category
category_nameVARCHAR(100)Human-readable category name
active_flagBOOLEANWhether the category is active
expenses
ColumnTypeDescription
expense_idPKINTPrimary key for the expense record
category_idINTForeign key to expense_categories.category_id
expense_dateDATEDate the expense was recorded
amountNUMERIC(12,2)Expense amount
statusVARCHAR(20)Recorded status such as approved, pending, or invalid
expense_rules
ColumnTypeDescription
statusPKVARCHAR(20)Status value allowed by the recording policy
is_allowedBOOLEANWhether the status is allowed
Tablesexpense_categoriesexpensesexpense_rules
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results