What is optimization, and what is a subquery in SQL?
Use the supplied PostgreSQL tables to demonstrate the subquery concept by finding customers whose settled transaction total exceeds the average settled total across transaction groups. Briefly explain how the query could be optimized.
customer_id, customer_name, and total_settled_amount.customer_id ascending.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| customer_id | INT | Customer associated with the transaction |
| amount | NUMERIC(12,2) | Transaction amount |
| status | VARCHAR(20) | Transaction processing status |