413. RFM Customer Segmentation

Medium E-Commerce Customer Segmentation
Query Rules
  • The query columns and order must match the expected result schema.
  • NULL values should be handled appropriately where applicable.
  • The grader compares output values and sorting order to evaluate.

Schema Browser

Click a table's header to toggle expand/collapse.
locations
3 cols
departments
3 cols
employees
6 cols
orders
6 cols

Reference Solution

Expected SQL
SELECT customer_name, CAST(JULIANDAY('2025-12-11') - JULIANDAY(MAX(order_date)) AS INTEGER) AS recency_days, COUNT(*) AS frequency, SUM(amount) AS monetary FROM orders GROUP BY customer_name ORDER BY monetary DESC;
SQL Editor
Ctrl+Enter to run
Console Output

Console Terminal

Write your query and click "Run Query" (Ctrl + Enter) to see results and testcase validation.