Skip to content

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.

Notifications You must be signed in to change notification settings

Sajjad-Ali-1411/Bank-Churn-Analysis-using-SQL-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bank-Customer-Churn-Analysis-using-SQL-

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.

🏦 Customer Churn Analysis Using SQL

πŸ“Œ Overview

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.


πŸ” Objective

To understand the key patterns that drive customer churn and to provide recommendations to improve customer retention strategies using data-driven decision-making.


πŸ“ Project Structure

  • customer_data.csv – Raw data
  • churn_analysis_queries.sql – All SQL queries used
  • README.md – Project documentation

πŸ“Š Dataset Summary

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

βš’οΈ Skills Applied

  • 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)

πŸ” Key Questions Solved

βœ… 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?


πŸ“ˆ Sample SQL Query

-- 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;

πŸ’‘ Key Insights

  • 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.

🧠 Business Recommendations

  • 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

πŸ“œ License

MIT License – for learning and personal use.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published