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 30, the output for the first day should be 50 (which is 30 from the second).
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 30, the output for the first day should be 50 (which is 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 |
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 |