You are given a table Transactions that contains information about financial transactions.
Table: Transactions
| Column Name | Type |
|---|---|
| transaction_id | int |
| day | datetime |
| amount | int |
transaction_id is the column with unique values for this table. Each row contains information about one transaction.
Write a solution to report the IDs of the transactions with the maximum amount on their respective day. If in one day there are multiple such transactions, return all of them.
Return the result table ordered by transaction_id in ascending order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
transaction_id
PK
|
int | Unique identifier for each transaction |
day
|
datetime | Date when the transaction occurred |
amount
|
int | Transaction amount |
Input & Output
| transaction_id | day | amount |
|---|---|---|
| 3 | 2021-01-01 | 1500 |
| 4 | 2021-01-01 | 1500 |
| 2 | 2021-01-02 | 2000 |
| 1 | 2021-01-02 | 1000 |
| transaction_id |
|---|
| 2 |
| 3 |
| 4 |
On 2021-01-01, both transactions 3 and 4 have the maximum amount of 1500. On 2021-01-02, transaction 2 has the maximum amount of 2000. All three transaction IDs are returned, ordered by transaction_id.
| transaction_id | day | amount |
|---|---|---|
| 1 | 2021-01-01 | 1000 |
| 2 | 2021-01-02 | 2000 |
| 3 | 2021-01-03 | 500 |
| transaction_id |
|---|
| 1 |
| 2 |
| 3 |
Each day has only one transaction, so each transaction has the maximum amount for its respective day. All transaction IDs are returned.
| transaction_id | day | amount |
|---|---|---|
| 5 | 2021-01-01 | 800 |
| 1 | 2021-01-01 | 1200 |
| 3 | 2021-01-01 | 1200 |
| 2 | 2021-01-01 | 900 |
| transaction_id |
|---|
| 1 |
| 3 |
On 2021-01-01, transactions 1 and 3 both have the maximum amount of 1200. Only these two transaction IDs are returned, ordered by transaction_id.
Constraints
-
1 ≤ transaction_id ≤ 10^5 -
dayis a valid datetime -
1 ≤ amount ≤ 10^6