Write a SQL query to identify duplicate transactions within a specific timeframe and aggregate their total value.
Use the timeframe from 2025-01-01 00:00:00+00 inclusive through 2025-02-01 00:00:00+00 exclusive. Treat transactions with the same account, merchant reference, timestamp, and amount as duplicates. Rows without a matching account number must be ignored.
account_number, merchant_reference, transaction_timestamp, amount, duplicate_count, and total_value.| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Internal account identifier |
| account_number | VARCHAR(20) | Customer-facing bank account number |
| account_type | VARCHAR(20) | Type of bank account |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| account_id | INT | Account associated with the transaction |
| merchant_reference | VARCHAR(30) | Reference supplied by the merchant |
| transaction_timestamp | TIMESTAMPTZ | Timestamp when the transaction was recorded |
| amount | NUMERIC(12,2) | Transaction amount in the account currency |
| status | VARCHAR(20) | Processing status |