Score Manual Journal Entries for Audit Risk in SQL
Last updated: November 29, 2026
Quick Overview
Given journal entry headers, lines and period close dates, write SQL that computes per-entry risk flags (unbalanced, weekend, after hours, round amount, manual entry near period close, rarely used poster) and returns entries whose weighted score meets a threshold.
PwC
November 29, 20260
0
0 solved
Given journal entry headers, lines and period close dates, write SQL that computes per-entry risk flags (unbalanced, weekend, after hours, round amount, manual entry near period close, rarely used poster) and returns entries whose weighted score meets a threshold.
Journal entry testing is required on every financial statement audit to address the risk of management override, and PwC runs it over full GL populations in its audit data tools. This screen checks that a data engineer can aggregate lines to entries correctly, express auditor criteria as transparent flags, and keep the logic explainable to an engagement team.
What the Interviewer Expects
- Aggregate lines to the entry level before applying entry-level tests
- Express each criterion as a separate 0/1 flag so results are explainable
- Join period close dates and compute a near-close window
- Compute per-user volume to identify infrequent posters
- Weight and threshold the flags, and order output for review
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you parameterize weights and thresholds per engagement?
- How would you test this against a GL extract with 200 million lines?
- How do you handle entries whose lines span time zones or have a missing posted_by?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
journal_headers(je_id, posted_at, posted_by, source, period), journal_lines(je_id, line_no, account, debit, credit), period_close(period, close_date). source distinguishes system feeds (AP, pa...
Approach
First roll lines up to one row per entry with total debits and credits. Then build one flag per criterion: unbalanced (debits not equal to credits, weight 3, since that should never happen), posted on...