← All projects

Do this marketplace's customers ever come back?

SQL, PostgreSQL · Code on GitHub

3.12% of customers ever place a second order

Across 99K+ orders from 96K customers, Olist is close to a one-purchase business. After a customer's first month, the chance they return in any later month stays below 0.5%. Revenue is concentrated too: the top 10% of customers bring in 38.5% of it.

The data

The public Brazilian E-Commerce dataset from Olist, on Kaggle: 99,441 orders from 96,096 unique customers between 2016 and 2018, spread across nine tables covering orders, items, payments, reviews, products, sellers and geography.

I wrote the analysis in PostgreSQL 16 as five query files, from schema through KPIs, customers, products and retention. I later built a Power BI dashboard on the same data to go with it.

What the numbers say

All values cover the full timespan of the dataset, 2016 to 2018.

Key findings
MetricValue
Total revenue$16.0M
Orders / unique customers99,441 / 96,096
Average order value (total payments per order)$160.99
Average customer lifetime value$166.59
Revenue from the top 10% of customers38.5% (top 20%: 53.8%)
Repeat-purchase rate3.12% of customers order more than once
Share of each month's customers who are new≈96%
Average time to a second purchase≈88 days, for customers who make one
Orders delivered after the estimated date7.87%
Average review score4.09 / 5
  • Retention is the weakest point. Average lifetime value ($166.59) is barely above the average single order ($160.99), because so few customers return. A cohort analysis shows the chance of a return in any month drops below 0.5% after the first month and stays there.
  • Revenue is concentrated. One in ten customers brings in more than a third of revenue, so losing a few high-value buyers costs far more than losing an average one.
  • No single product or category dominates revenue.
  • Delivery is usually early, about 10 days ahead of the estimate on average. 7.87% of orders arrive late, and the worst case is about six months late.

How it's built

Each query file answers a set of questions and is followed by a short comment recording what it returned and what it means.

Query files
FileQuestions answered
01_schema.sqlCreates the nine Olist tables with primary keys
02_kpis.sqlRevenue and month-over-month revenue, unique customers, new vs returning customers by month, order count, average order value, repeat-purchase rate, monthly cohort retention, review score, delivery delay
03_customer.sqlCustomer lifetime value, revenue share by customer decile (running totals with window functions), distribution of orders per customer
04_product.sqlRevenue share by product and by category, average review by category
05_retention.sqlDays from first to second purchase, repeat rate by first-purchase cohort

Techniques: multi-step CTEs, window functions (LAG, ROW_NUMBER, running SUM and COUNT with OVER), cohort construction with DATE_TRUNC and AGE, and conditional aggregation with CASE.

Limitations

  • The 7.87% late-delivery figure is a rate only. I did not measure whether late orders affect reviews, revenue or repeat purchases.
  • The analysis describes what happened in one marketplace between 2016 and 2018. It shows that customers rarely return, not why.
  • The outputs are static query results. The interactive version, filterable by customer decile, state and date range, is the dashboard.