Find Offboarded Employees Who Still Have Active Accounts

Last updated: November 29, 2026

Quick Overview

Using an employees table from the HR system and an accounts table synced from integrations like GitHub, AWS and Slack, write SQL that lists every active account belonging to someone offboarded more than a grace period ago, flagging accounts used after the offboarding date.

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

0

0

0 solved


Using an employees table from the HR system and an accounts table synced from integrations like GitHub, AWS and Slack, write SQL that lists every active account belonging to someone offboarded more than a grace period ago, flagging accounts used after the offboarding date.

Timely offboarding is one of the most common controls Vanta tests, and the real difficulty is linking accounts to people when integrations do not share an id. The interviewer looks for correct joins, case-insensitive email fallback matching, and an output ordered by risk.

What the Interviewer Expects
  • Joins on employee_id and falls back to case-insensitive email
  • Filters to offboarded employees and active accounts only
  • Applies the grace period relative to an as-of date, not now()
  • Flags last login after offboarding as the highest-risk case
  • Orders by risk for the reviewer
Key Topics to Cover
joins
date arithmetic
identity matching
CTEs
filtering
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 match accounts that use a personal email or a GitHub handle?
  • How do you avoid double counting when both id and email match?
  • Write the version that tracks how long each account stayed active after offboarding, historically.
  • Which accounts should be excluded (service accounts, shared mailboxes)?
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

employees(id, email, status, offboarded_at) comes from the HRIS. accounts(id, integration, account_email, employee_id, is_active, last_login_at) comes from integrations; employee_id is set when ...

Approach

Join accounts to employees on employee_id, or when it is null, on lowercased email. Keep offboarded employees with active accounts older than the grace period. Compute days since offboarding and whe...


Submit Your Answer
Markdown supported

Related Questions