Chapter 6 · Subqueries
31. Dormant Accounts (No Recent Transactions)
Medium20 XPFinance
Identify active accounts that have had no transactions in the last 90 days (relative to the most recent transaction_date in the database). Return account id, account_type, balance, and the last_txn_date for the account. Use a subquery to determine the cutoff date. Order by last_txn_date ascending.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- account_typeTEXT
- balanceREAL
- currencyTEXT
- opened_atTEXT
- statusTEXT
- PKidINT
- FKaccount_id→ accounts.idINT
- transaction_dateTEXT
- typeTEXT
- amountREAL
- balance_afterREAL
- descriptionTEXT
- reference_numberTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.