Practice Interview Questions
| Question | Status |
|---|---|
Given a table of transactions with transaction dates and amounts, write a SQL query to calculate the running total for each day.
For instance, if transactions on the first day total $20 and on the second day total $30, the output for the first day should be $20 and for the second day $50 (which is $20 from the first day plus $30 from the second).
transactions table:
| Column Name | Description |
|---|---|
| id | Identifier for each transaction |
| transaction_date | Date the transaction occurred |
| amount | The amount of the transaction |
Given a table of transactions with transaction dates and amounts, write a SQL query to calculate the running total for each day.
For instance, if transactions on the first day total $20 and on the second day total $30, the output for the first day should be $20 and for the second day $50 (which is $20 from the first day plus $30 from the second).
transactions table:
| Column Name | Description |
|---|---|
| id | Identifier for each transaction |
| transaction_date | Date the transaction occurred |
| amount | The amount of the transaction |
| date |
|---|
| running_total |
|---|
| 2022-01-01 | 300.00 |
| 2022-01-02 | 350.00 |
| 2022-01-03 | 700.00 |
| date |
|---|
| running_total |
|---|
| 2022-01-01 | 300.00 |
| 2022-01-02 | 350.00 |
| 2022-01-03 | 700.00 |