Your question is SQL Fraud Detection: Two Cities. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Capital One's fraud analytics team wants to flag accounts showing rapid geographic movement. A potential alert occurs when the same account has transactions in different cities within one hour.
Write a PostgreSQL query that returns every qualifying pair of transactions for valid Capital One accounts.
accounts.| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique Capital One account identifier |
| account_name | VARCHAR(100) | Account holder label |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| account_id | INT | Account associated with the transaction |
| transaction_ts | TIMESTAMP | Transaction timestamp |
| city | VARCHAR(100) | City where the transaction occurred |
| amount | NUMERIC(12,2) | Transaction amount |