Query Evidence Files That Have Outlived Their Retention Policy

Last updated: November 29, 2026

Quick Overview

Write SQL that lists evidence files whose agency and category retention period has elapsed, excluding files already deleted, categories kept indefinitely, and any file linked to a case that is still open.

Axon
Data Manipulation (SQL/Python)
Data Engineer
Axon
November 29, 2026
Data Engineer
Technical Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Write SQL that lists evidence files whose agency and category retention period has elapsed, excluding files already deleted, categories kept indefinitely, and any file linked to a case that is still open.

Retention is a core Axon Evidence feature: agencies configure how long each category (traffic stop, felony, use of force) is kept, and open cases must hold footage. This screen checks joins, NULL semantics and an anti-join, written carefully because a wrong row means deleting evidence.

What the Interviewer Expects
  • Join evidence to the per-agency per-category policy
  • Treat NULL retention as keep forever, not as zero
  • Exclude soft-deleted rows
  • Use NOT EXISTS for the open-case hold
  • Mention what happens to evidence with no matching policy
Key Topics to Cover
joins
anti-join
NULL handling
date arithmetic
data retention
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you run this safely as a nightly deletion job?
  • How would you show agencies a 30-day preview before deletion?
  • What if a file belongs to two cases, one closed and one open?
  • How would you index these tables for millions of files per agency?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Tables: evidence(evidence_id, agency_id, category, captured_at, deleted_at), retention_policy(agency_id, category, retention_days) where NULL means indefinite, `evidence_case(evidence_id, case_id)...

Approach

Inner join to the policy, so unmatched categories fall out (safe default). Compute expires_on = captured_at + retention_days. Filter to not deleted, non-NULL retention, and expired. Remove anything ...


Submit Your Answer
Markdown supported

Related Questions