A data analytics project using PostgreSQL to explore and visualize customer churn behavior in a bank's customer dataset. This project demonstrates how raw tabular data can be analyzed using pure SQL queries to extract business insights and support customer retention strategies.
This project analyzes a bank's customer data to explore churn behavior, identify risk segments, and provide actionable insights using pure SQL queries.
It demonstrates strong SQL skills across data profiling, segmentation, aggregations, and business intelligence use cases.
To understand the key patterns that drive customer churn and to provide recommendations to improve customer retention strategies using data-driven decision-making.
customer_data.csvβ Raw datachurn_analysis_queries.sqlβ All SQL queries usedREADME.mdβ Project documentation
The dataset contains information on 10,000+ bank customers including:
| Column | Description |
|---|---|
| CustomerId | Unique ID for each customer |
| Surname | Customer's surname |
| CreditScore | Credit score (300β900) |
| Geography | Country (France, Spain, Germany) |
| Gender | Male/Female |
| Age | Age of the customer |
| Tenure | Years the customer has stayed |
| Balance | Account balance |
| NumOfProducts | Bank products the customer uses |
| HasCrCard | Has a credit card (TRUE/FALSE) |
| IsActiveMember | Recently active (TRUE/FALSE) |
| EstimatedSalary | Salary estimate |
| Exited | 1 = Customer Churned, 0 = Retained |
- SQL (PostgreSQL)
- Aggregations (
SUM,AVG,COUNT) - Conditional logic with
CASE WHEN - Filtering with
WHERE,HAVING - Grouping & Segmentation using
GROUP BY - Window functions & CTEs (for advanced cases)
- Sorting and limiting (
ORDER BY,LIMIT)
- Aggregations (
β
What is the overall churn rate?
β
Which geography has the highest churn?
β
Does credit score, age, or balance impact churn?
β
Are inactive customers more likely to churn?
β
Which high-value customers (by balance/salary) have churned?
β
Which segment (age/credit score/tenure) is at highest risk?
-- Churn rate by Geography
SELECT Geography,
COUNT(*) AS total_customers,
SUM(CASE WHEN Exited THEN 1 ELSE 0 END) AS churned,
ROUND(100.0 * SUM(CASE WHEN Exited THEN 1 ELSE 0 END) / COUNT(*), 2) AS churn_rate
FROM customer_data
GROUP BY Geography
ORDER BY churn_rate DESC;- Germany shows the highest churn rate among geographies.
- Customers aged above 50 have significantly higher churn.
- Inactive customers with high balances are at major risk.
- Customers with 1 product and low engagement tend to churn more.
- Launch loyalty programs for high-balance inactive users.
- Monitor customers in the 50+ age group and provide engagement triggers.
- Offer bundled products or perks to low-product customers.
- Targeted offers for customers with multiple products but low engagement
MIT License β for learning and personal use.