๐ SQL Project Series #6: Banking Transaction Analysis ๐ฆ
Learn how banks use SQL to analyze customer transactions, monitor account activity, detect fraud, and generate business insights.
๐ฏ Business Objectives
โ
Analyze customer transactions
โ
Calculate account balances
โ
Identify high-value customers
โ
Detect suspicious transactions
โ
Monitor transaction trends
โ
Analyze deposits vs withdrawals
โ
Measure customer activity
โ
Identify dormant accounts
โ
Generate banking KPIs
๐ Step 1: Create Database
CREATE DATABASE banking_db;
USE banking_db;
๐ Step 2: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
gender VARCHAR(10),
city VARCHAR(50),
account_open_date DATE
);
๐ Step 3: Create Accounts Table
CREATE TABLE accounts (
account_id INT PRIMARY KEY,
customer_id INT,
account_type VARCHAR(30),
branch_name VARCHAR(100),
opening_balance DECIMAL(12,2),
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id)
);
๐ Step 4: Create Transactions Table
CREATE TABLE transactions (
transaction_id INT PRIMARY KEY,
account_id INT,
transaction_date TIMESTAMP,
transaction_type VARCHAR(20),
amount DECIMAL(12,2),
FOREIGN KEY (account_id)
REFERENCES accounts(account_id)
);
๐ Step 5: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Male','Mumbai','2023-01-10'),
(2,'Priya Verma','Female','Delhi','2023-02-18'),
(3,'Amit Patel','Male','Pune','2023-04-12'),
(4,'Sneha Joshi','Female','Bangalore','2023-05-22'),
(5,'Rohan Gupta','Male','Hyderabad','2023-08-01');
๐ Step 6: Insert Sample Accounts
INSERT INTO accounts VALUES
(101,1,'Savings','Mumbai',50000),
(102,2,'Savings','Delhi',35000),
(103,3,'Current','Pune',100000),
(104,4,'Savings','Bangalore',45000),
(105,5,'Current','Hyderabad',75000);
๐ Step 7: Insert Sample Transactions
INSERT INTO transactions VALUES
(1001,101,'2025-01-05 10:15:00','Deposit',15000),
(1002,101,'2025-01-06 12:30:00','Withdrawal',5000),
(1003,102,'2025-01-07 14:20:00','Deposit',25000),
(1004,103,'2025-01-08 16:10:00','Withdrawal',30000),
(1005,104,'2025-01-09 09:45:00','Deposit',12000),
(1006,105,'2025-01-10 11:00:00','Withdrawal',10000);
๐ง SQL Concepts You'll Practice
โ DDL Commands
โ DML Commands
โ Primary & Foreign Keys
โ Joins
โ Aggregate Functions
โ CASE WHEN
โ GROUP BY
โ HAVING
โ Window Functions
โ CTEs
โ Date & Time Functions
๐ Business KPIs You Can Build
๐ Total Transaction Amount
๐ Total Deposits
๐ Total Withdrawals
๐ Net Cash Flow
๐ Current Account Balance
๐ Average Transaction Amount
๐ Daily Transaction Volume
๐ Monthly Transaction Trend
๐ Branch-wise Transactions
๐ Account Type Analysis
๐ Top Customers by Transaction Value
๐ Most Active Customers
๐ Dormant Accounts
๐ High-Value Transactions
๐ Deposit vs Withdrawal Ratio
๐ Fraud Detection Alerts
๐ Average Balance by Branch
๐ Customer Growth
๐ Transaction Success Rate
๐ Peak Transaction Hours
๐ก Double Tap โค๏ธ For More
Post #2589
2.1K
- โค 4
- ๐ 1