Back to Projects

Customer Segmentation

SQL · PostgreSQL · RFM Analysis 2026

Overview

This project uses SQL to perform RFM (Recency, Frequency, Monetary) analysis on an e-commerce transactions database, segmenting customers into groups such as Champions, At-Risk, and Lost — enabling targeted retention campaigns.

Methodology

  • Queried raw transactional data from a PostgreSQL database spanning 18 months
  • Calculated RFM scores per customer using window functions and CTEs
  • Defined score thresholds to classify customers into 5 segments
  • Exported segment summary tables for use in marketing dashboards

Screenshots

RFM score distribution — replace with real screenshot
Customer segment breakdown table — replace with real screenshot

Results

Identified that 12% of customers were "Champions" responsible for 48% of revenue, while 23% were "At-Risk" — enabling focused re-engagement campaigns targeting high-value churners.