SQL QuestSQL Interview Questions › Joins

Dormant Cards — No Transactions in the Last 14 Days

MediumFreeQuerying BasicsJoinsNULL HandlingSubqueries & CTEsDate Functions

Retention teams call these dormant cards. The ledger's last day is 2026-05-03; treat "the last 14 days" as transactions on or after 2026-04-19. Find every account with NO transaction in that window — an anti-join. Put the recent transactions in a CTE, LEFT JOIN accounts to it, and keep the rows where the join found nothing (IS NULL). NOT EXISTS is the equivalent subquery form.

Return account_id, email, country, and last_txn_at (the account's most recent transaction timestamp in the whole ledger, any date). Order by last_txn_at ascending, then account_id ascending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

accounts

account_idemailsignup_atcountrydevice_fingerprintip_blockstatus
1user1@example.com2026-02-24T00:00:00.000ZTRdev_13c0cdad41.116.196.153active
2user2@inbox.dev2025-05-13T00:00:00.000ZJPdev_26576d4938.98.201.102active
3user3@inbox.dev2026-04-25T00:00:00.000ZJPdev_42f1a115190.77.45.244flagged

transactions

txn_idaccount_idamounttxn_atmerchant_idlatlngstatus
1149151.842026-03-04T12:39:39.078Z2440.342-74.4092completed
22110.722026-03-04T13:04:50.641Z752.936613.3229completed
335158.782026-03-04T13:27:15.528Z2552.739713.3134completed

Expected output: 11 accounts with no transaction on or after 2026-04-19

Hint

The hint for this one spells out most of the query, so it stays in the editor. Reach for SELECT, LEFT JOIN, IS NULL, and open the hint there if you stall.

Concepts

SELECT LEFT JOIN IS NULL CTE Date Functions Anti-Join + CTE

Practise the topic: SQL practice questions · JOIN practice · NULL handling practice · CTE practice · Date function practice

In these company practice sets

Capital One · Plaid

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Customers Who Never OrderedMedium · FreeAbove-Average Departments (Derived Table)Medium · FreeLEFT JOIN NULL Semantics: Inactive CustomersMedium · FreeManagement Hierarchy OverviewMedium · FreeCount Direct ReportsMedium · FreeCustomer Recency AnalysisMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test