About the “RFM (Recency, Frequency, Monetary) Customer Segmentation” SQL Problem
Business Scenario
E-commerce CRM marketing divides customers by RFM metrics: Recency (days between a reference audit date of '2024-04-01' and customer's latest order), Frequency (order count), and Monetary (total spend).
Expected Output & Criteria
Customer profiles with Recency, Frequency, and Monetary metrics.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMThis challenge executes directly against the following relational schema in your browser:
CREATE TABLE ecom_transactions (
txn_id INT PRIMARY KEY,
customer_id INT NOT NULL,
order_date DATE NOT NULL,
amount NUMERIC(10, 2) NOT NULL
);Target SQL Clauses & Operators
GROUP BYSUMCOUNTORDER BY
Want more Business Analytics practice?
Explore the full syllabus of 14 exercises, syntax guides, and interview pitfalls.