Explain how you would write a SQL query to calculate a running total over time.
Use a single transaction table with one row per transaction. Return the cumulative amount in chronological order, and make sure the total increases as time advances. If multiple transactions occur on the same date, preserve a deterministic order.
transaction_date, amount, running_totaltransaction_date, then transaction_id| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| transaction_date | DATE | Date the transaction occurred |
| amount | NUMERIC(12,2) | Transaction amount, positive or negative |
| channel | VARCHAR(20) | Optional transaction channel |