Tell me about your experience using SQL functions like DISTINCT, aggregate functions, and TOP, including how you apply them in business analysis queries.
Using PostgreSQL, demonstrate this by analyzing completed orders. Return the top three customer segments by total order value, while counting unique customers. PostgreSQL uses LIMIT rather than TOP.
segment, distinct_customers, and total_order_value.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer name |
| segment | VARCHAR(50) | Customer business segment |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| status | VARCHAR(20) | Order lifecycle status |
| order_value | NUMERIC(12,2) | Monetary value of the order |