About the “Customer Initial vs Recent Order with FIRST_VALUE()” SQL Problem
Business Scenario
CRM retention teams want to analyze order size expansion over customer lifecycles by contrasting the customer's initial purchase against subsequent orders.
Expected Output & Criteria
Order history showing order amount alongside the customer first purchase value.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMThis challenge executes directly against the following relational schema in your browser:
CREATE TABLE customer_purchases (
order_id INT PRIMARY KEY,
customer_id INT NOT NULL,
order_date DATE NOT NULL,
order_amount NUMERIC(10, 2) NOT NULL
);Target SQL Clauses & Operators
FIRST_VALUEOVERPARTITION BY
Want more Window Functions practice?
Explore the full syllabus of 14 exercises, syntax guides, and interview pitfalls.