TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2618 2.44K
๐Ÿš€ SQL Project Series #17
Credit Card Transaction Analytics ๐Ÿ’ณ

Analyze credit card customers, merchants, transactions, spending behavior, and fraud patterns using SQL to improve customer experience and reduce financial risk.

๐ŸŽฏ Business Objectives
โœ… Analyze customer spending patterns
โœ… Monitor transaction volume and value
โœ… Identify high-value customers
โœ… Detect suspicious transactions
โœ… Measure merchant performance
โœ… Track card usage trends
โœ… Analyze payment success rates
โœ… Build executive dashboards

๐Ÿ“‚ Step 1: Create Database
CREATE DATABASE credit_card_db;
USE credit_card_db;

๐Ÿ“‚ Step 2: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
gender VARCHAR(10),
city VARCHAR(50),
card_type VARCHAR(30)
);

๐Ÿ“‚ Step 3: Create Merchants Table
CREATE TABLE merchants (
merchant_id INT PRIMARY KEY,
merchant_name VARCHAR(100),
merchant_category VARCHAR(50),
city VARCHAR(50)
);

๐Ÿ“‚ Step 4: Create Transactions Table
CREATE TABLE transactions (
transaction_id INT PRIMARY KEY,
customer_id INT,
merchant_id INT,
transaction_date DATETIME,
amount DECIMAL(10,2),
payment_status VARCHAR(20),
payment_method VARCHAR(20),
FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
FOREIGN KEY (merchant_id) REFERENCES merchants(merchant_id)
);

๐Ÿ“‚ Step 5: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Male','Mumbai','Platinum'),
(2,'Priya Verma','Female','Delhi','Gold'),
(3,'Amit Patel','Male','Pune','Silver'),
(4,'Sneha Joshi','Female','Bangalore','Gold'),
(5,'Rohan Gupta','Male','Hyderabad','Platinum');

๐Ÿ“‚ Step 6: Insert Sample Merchants
INSERT INTO merchants VALUES
(101,'Amazon','E-commerce','Bangalore'),
(102,'Reliance Fresh','Retail','Mumbai'),
(103,'Indian Oil','Fuel','Delhi'),
(104,'Apollo Pharmacy','Healthcare','Pune'),
(105,'BookMyShow','Entertainment','Mumbai');

๐Ÿ“‚ Step 7: Insert Sample Transactions
INSERT INTO transactions VALUES
(1001,1,101,'2025-01-05 10:15:00',4500,'Success','Credit Card'),
(1002,2,102,'2025-01-05 13:45:00',1800,'Success','Credit Card'),
(1003,3,103,'2025-01-06 08:20:00',3200,'Failed','Credit Card'),
(1004,4,104,'2025-01-06 17:10:00',950,'Success','Credit Card'),
(1005,5,105,'2025-01-07 20:30:00',2200,'Success','Credit Card');

๐Ÿง  SQL Concepts You'll Practice
โœ” DDL & DML
โœ” INNER JOIN
โœ” LEFT JOIN
โœ” Aggregate Functions
โœ” GROUP BY
โœ” HAVING
โœ” CASE WHEN
โœ” Date & Time Functions
โœ” CTEs
โœ” Window Functions
โœ” Ranking Functions

๐Ÿ“Š Business KPIs You Can Build
๐Ÿ“ˆ Total Customers
๐Ÿ“ˆ Active Cardholders
๐Ÿ“ˆ Total Transactions
๐Ÿ“ˆ Successful Transactions
๐Ÿ“ˆ Failed Transactions
๐Ÿ“ˆ Transaction Success Rate
๐Ÿ“ˆ Total Transaction Value
๐Ÿ“ˆ Average Transaction Value
๐Ÿ“ˆ Spend by Customer
๐Ÿ“ˆ Spend by Merchant
๐Ÿ“ˆ Spend by Merchant Category
๐Ÿ“ˆ Spend by City
๐Ÿ“ˆ Peak Transaction Hours
๐Ÿ“ˆ Peak Transaction Days
๐Ÿ“ˆ Top Spending Customers
๐Ÿ“ˆ Top Merchants
๐Ÿ“ˆ Card Type Usage
๐Ÿ“ˆ High-Value Transactions
๐Ÿ“ˆ Suspicious Transaction Detection
๐Ÿ“ˆ Customer Spending Trend
๐Ÿ“ˆ Merchant Performance Dashboard
๐Ÿ“ˆ Revenue Contribution by Category
๐Ÿ“ˆ Executive Banking Dashboard

๐ŸŽฏ This project reflects real-world SQL analysis performed by Banking Analysts, Fraud Analysts, Risk Analysts, Product Analysts, and Business Intelligence teams in banks, payment companies, and fintech organizations.

๐Ÿ’ก Double Tap โค๏ธ For More
  • โค 12
More from @sqlanalyst
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026SQL Interview Series โ€” Part 4 ๐Ÿ“Œ Question 4: Find the Highest Salary in Each Department Suโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Sep 29, 2026SQL Interview Series โ€” Part 2 ๐Ÿ“Œ Question 2: Find Duplicate Records Suppose you have an Emโ€ฆ
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’