Your question is Second-Highest Value With Window Functions. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Tiger Analytics is reviewing completed transaction activity for active clients. Write a PostgreSQL query to identify the second-highest transaction value, including every transaction tied at that rank.
transactions with clients and consider only clients whose status is active.transaction_status = 'completed' and a non-NULL transaction_value.DENSE_RANK() to rank distinct transaction values from highest to lowest.| Column | Type | Description |
|---|---|---|
| client_idPK | INT | Primary key for the client |
| client_name | VARCHAR(100) | Client name |
| segment | VARCHAR(30) | Client business segment |
| status | VARCHAR(20) | Client account status |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Primary key for the transaction |
| client_id | INT | References clients.client_id |
| transaction_value | DECIMAL(12,2) | Monetary value of the transaction |
| transaction_status | VARCHAR(20) | Current transaction status |
| payment_method | VARCHAR(30) | Payment method used |