๐ ๐๐ฎ๐๐ฎ ๐๐ป๐ฎ๐น๐๐๐ถ๐ฐ๐ ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐
Data Analytics is one of the most in-demand skills in todayโs job market ๐ป
โ Beginner Friendly
โ Industry-Relevant Curriculum
โ Certification Included
โ 100% Online
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4wh2ugB
๐ฏ Donโt miss this opportunity to build high-demand skills!
Data Analytics is one of the most in-demand skills in todayโs job market ๐ป
โ Beginner Friendly
โ Industry-Relevant Curriculum
โ Certification Included
โ 100% Online
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4wh2ugB
๐ฏ Donโt miss this opportunity to build high-demand skills!
โค2
๐ SQL Project Series #16: Insurance Claims Analytics ๐ฅ
Analyze insurance policies, customers, claims, premiums, and settlements using SQL to improve claim processing, detect fraud, and measure business performance.
๐ฏ Business Objectives
โ Track insurance policies
โ Analyze customer demographics
โ Monitor claim submissions
โ Measure claim approval rates
โ Detect fraudulent claims
โ Analyze premium collections
โ Evaluate claim settlement time
โ Build insurance dashboards
๐ Step 1: Create Database
CREATE DATABASE insurance_db;
USE insurance_db;
๐ Step 2: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
gender VARCHAR(10),
age INT,
city VARCHAR(50)
);
๐ Step 3: Create Policies Table
CREATE TABLE policies (
policy_id INT PRIMARY KEY,
customer_id INT,
policy_type VARCHAR(50),
premium_amount DECIMAL(10,2),
start_date DATE,
end_date DATE,
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id)
);
๐ Step 4: Create Claims Table
CREATE TABLE claims (
claim_id INT PRIMARY KEY,
policy_id INT,
claim_date DATE,
claim_amount DECIMAL(10,2),
approved_amount DECIMAL(10,2),
claim_status VARCHAR(30),
settlement_date DATE,
FOREIGN KEY (policy_id)
REFERENCES policies(policy_id)
);
๐ Step 5: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Male',32,'Mumbai'),
(2,'Priya Verma','Female',29,'Delhi'),
(3,'Amit Patel','Male',41,'Pune'),
(4,'Sneha Joshi','Female',36,'Bangalore'),
(5,'Rohan Gupta','Male',45,'Hyderabad');
๐ Step 6: Insert Sample Policies
INSERT INTO policies VALUES
(101,1,'Health',15000,'2025-01-01','2025-12-31'),
(102,2,'Motor',12000,'2025-02-01','2026-01-31'),
(103,3,'Life',25000,'2025-01-15','2035-01-14'),
(104,4,'Health',18000,'2025-03-01','2026-02-28'),
(105,5,'Motor',10000,'2025-04-01','2026-03-31');
๐ Step 7: Insert Sample Claims
INSERT INTO claims VALUES
(1001,101,'2025-03-10',25000,22000,'Approved','2025-03-18'),
(1002,102,'2025-04-05',18000,0,'Rejected',NULL),
(1003,103,'2025-05-12',50000,48000,'Approved','2025-05-22'),
(1004,104,'2025-06-08',12000,10000,'Approved','2025-06-15'),
(1005,105,'2025-07-01',15000,14000,'Under Review',NULL);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ INNER JOIN
โ LEFT JOIN
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
๐ Business KPIs You Can Build
๐ Total Customers
๐ Total Active Policies
๐ Policies by Type
๐ Total Premium Collected
๐ Average Premium Amount
๐ Total Claims Submitted
๐ Total Approved Claims
๐ Total Rejected Claims
๐ Claim Approval Rate
๐ Claim Rejection Rate
๐ Total Claim Amount
๐ Total Approved Amount
๐ Average Claim Amount
๐ Claim Settlement Time
๐ Claims by Policy Type
๐ Claims by City
๐ High-Value Claims
๐ Monthly Claim Trend
๐ Premium vs Claim Ratio
๐ Fraud Detection Candidates
๐ Customer Lifetime Value
๐ Policy Renewal Trend
๐ Executive Insurance Dashboard
๐ฏ This project reflects real-world SQL analysis performed by Insurance Analysts, Risk Analysts, Claims Operations teams, Fraud Detection teams, and Business Intelligence professionals to improve operational efficiency, manage risk, and enhance customer service.
๐ก Double Tap โค๏ธ For More
Analyze insurance policies, customers, claims, premiums, and settlements using SQL to improve claim processing, detect fraud, and measure business performance.
๐ฏ Business Objectives
โ Track insurance policies
โ Analyze customer demographics
โ Monitor claim submissions
โ Measure claim approval rates
โ Detect fraudulent claims
โ Analyze premium collections
โ Evaluate claim settlement time
โ Build insurance dashboards
๐ Step 1: Create Database
CREATE DATABASE insurance_db;
USE insurance_db;
๐ Step 2: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
gender VARCHAR(10),
age INT,
city VARCHAR(50)
);
๐ Step 3: Create Policies Table
CREATE TABLE policies (
policy_id INT PRIMARY KEY,
customer_id INT,
policy_type VARCHAR(50),
premium_amount DECIMAL(10,2),
start_date DATE,
end_date DATE,
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id)
);
๐ Step 4: Create Claims Table
CREATE TABLE claims (
claim_id INT PRIMARY KEY,
policy_id INT,
claim_date DATE,
claim_amount DECIMAL(10,2),
approved_amount DECIMAL(10,2),
claim_status VARCHAR(30),
settlement_date DATE,
FOREIGN KEY (policy_id)
REFERENCES policies(policy_id)
);
๐ Step 5: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Male',32,'Mumbai'),
(2,'Priya Verma','Female',29,'Delhi'),
(3,'Amit Patel','Male',41,'Pune'),
(4,'Sneha Joshi','Female',36,'Bangalore'),
(5,'Rohan Gupta','Male',45,'Hyderabad');
๐ Step 6: Insert Sample Policies
INSERT INTO policies VALUES
(101,1,'Health',15000,'2025-01-01','2025-12-31'),
(102,2,'Motor',12000,'2025-02-01','2026-01-31'),
(103,3,'Life',25000,'2025-01-15','2035-01-14'),
(104,4,'Health',18000,'2025-03-01','2026-02-28'),
(105,5,'Motor',10000,'2025-04-01','2026-03-31');
๐ Step 7: Insert Sample Claims
INSERT INTO claims VALUES
(1001,101,'2025-03-10',25000,22000,'Approved','2025-03-18'),
(1002,102,'2025-04-05',18000,0,'Rejected',NULL),
(1003,103,'2025-05-12',50000,48000,'Approved','2025-05-22'),
(1004,104,'2025-06-08',12000,10000,'Approved','2025-06-15'),
(1005,105,'2025-07-01',15000,14000,'Under Review',NULL);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ INNER JOIN
โ LEFT JOIN
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
๐ Business KPIs You Can Build
๐ Total Customers
๐ Total Active Policies
๐ Policies by Type
๐ Total Premium Collected
๐ Average Premium Amount
๐ Total Claims Submitted
๐ Total Approved Claims
๐ Total Rejected Claims
๐ Claim Approval Rate
๐ Claim Rejection Rate
๐ Total Claim Amount
๐ Total Approved Amount
๐ Average Claim Amount
๐ Claim Settlement Time
๐ Claims by Policy Type
๐ Claims by City
๐ High-Value Claims
๐ Monthly Claim Trend
๐ Premium vs Claim Ratio
๐ Fraud Detection Candidates
๐ Customer Lifetime Value
๐ Policy Renewal Trend
๐ Executive Insurance Dashboard
๐ฏ This project reflects real-world SQL analysis performed by Insurance Analysts, Risk Analysts, Claims Operations teams, Fraud Detection teams, and Business Intelligence professionals to improve operational efficiency, manage risk, and enhance customer service.
๐ก Double Tap โค๏ธ For More
โค12
๐ ๐๐ & ๐ ๐ฎ๐ฐ๐ต๐ถ๐ป๐ฒ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ฅ
Learn the most in-demand AI skills from scratch and strengthen your profile with industry-recognized certificates! ๐
โ Beginner-Friendly Courses
โ Learn Online at Your Own Pace
โ 100% FREE of cost
Perfect for Students, Freshers & Working Professionals looking to build a career in AI/ML. ๐ผ
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4phANS2
๐ข Share this with your friends who want to start their AI career!
Learn the most in-demand AI skills from scratch and strengthen your profile with industry-recognized certificates! ๐
โ Beginner-Friendly Courses
โ Learn Online at Your Own Pace
โ 100% FREE of cost
Perfect for Students, Freshers & Working Professionals looking to build a career in AI/ML. ๐ผ
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4phANS2
๐ข Share this with your friends who want to start their AI career!
๐ฏ ๐๐ฌ๐ฌ๐๐ง๐ญ๐ข๐๐ฅ ๐๐๐๐ ๐๐๐๐๐๐๐ ๐๐๐๐๐๐ ๐๐ก๐๐ญ ๐๐๐๐ซ๐ฎ๐ข๐ญ๐๐ซ๐ฌ ๐๐จ๐จ๐ค ๐
๐จ๐ซ ๐ฏ
If you're applying for Data Analyst roles, having technical skills like SQL and Power BI is importantโbut recruiters look for more than just tools!
๐น 1๏ธโฃ ๐๐๐ ๐ข๐ฌ ๐๐๐๐ ๐โ๐๐๐ฌ๐ญ๐๐ซ ๐๐ญ
โ Know how to write optimized queries (not just SELECT * from everywhere!)
โ Be comfortable with JOINS, CTEs, Window Functions & Performance Optimization
โ Practice solving real-world business scenarios using SQL
๐ก Example Question: How would you find the top 5 best-selling products in each category using SQL?
๐น 2๏ธโฃ ๐๐ฎ๐ฌ๐ข๐ง๐๐ฌ๐ฌ ๐๐๐ฎ๐ฆ๐๐ง: ๐๐ก๐ข๐ง๐ค ๐๐ข๐ค๐ ๐ ๐๐๐๐ข๐ฌ๐ข๐จ๐ง-๐๐๐ค๐๐ซ
โ Understand the why behind the dataโnot just the numbers
โ Learn how to frame insights for different stakeholders (Tech & Non-Tech)
โ Use data storytellingโsimplify complex findings into actionable takeaways
๐ก Example: Instead of saying, "Revenue increased by 12%," say "Revenue increased 12% after launching a targeted discount campaign, driving a 20% increase in repeat purchases."
๐น 3๏ธโฃ ๐๐จ๐ฐ๐๐ซ ๐๐ / ๐๐๐๐ฅ๐๐๐ฎโ๐๐๐ค๐ ๐๐๐ฌ๐ก๐๐จ๐๐ซ๐๐ฌ ๐๐ก๐๐ญ ๐๐ฉ๐๐๐ค!
โ Avoid overloading dashboards with too many visualsโfocus on key KPIs
โ Use interactive elements (filters, drill-throughs) for better usability
โ Keep visuals simple & clearโbar charts are better than complex pie charts!
๐ก Tip: Before creating a dashboard, ask: "What business problem does this solve?"
๐น 4๏ธโฃ ๐๐ฒ๐ญ๐ก๐จ๐ง & ๐๐ฑ๐๐๐ฅโ๐๐๐ง๐๐ฅ๐ ๐๐๐ญ๐ ๐๐๐๐ข๐๐ข๐๐ง๐ญ๐ฅ๐ฒ
โ Python for data wrangling, EDA & automation (Pandas, NumPy, Seaborn)
โ Excel for quick analysis, PivotTables, VLOOKUP/XLOOKUP, Power Query
โ Know when to use Excel vs. Python (hint: small vs. large datasets)
Being a Data Analyst is more than just running queriesโitโs about understanding the business, making insights actionable, and communicating effectively!
Free Resources: https://t.me/sqlspecialist
If you're applying for Data Analyst roles, having technical skills like SQL and Power BI is importantโbut recruiters look for more than just tools!
๐น 1๏ธโฃ ๐๐๐ ๐ข๐ฌ ๐๐๐๐ ๐โ๐๐๐ฌ๐ญ๐๐ซ ๐๐ญ
โ Know how to write optimized queries (not just SELECT * from everywhere!)
โ Be comfortable with JOINS, CTEs, Window Functions & Performance Optimization
โ Practice solving real-world business scenarios using SQL
๐ก Example Question: How would you find the top 5 best-selling products in each category using SQL?
๐น 2๏ธโฃ ๐๐ฎ๐ฌ๐ข๐ง๐๐ฌ๐ฌ ๐๐๐ฎ๐ฆ๐๐ง: ๐๐ก๐ข๐ง๐ค ๐๐ข๐ค๐ ๐ ๐๐๐๐ข๐ฌ๐ข๐จ๐ง-๐๐๐ค๐๐ซ
โ Understand the why behind the dataโnot just the numbers
โ Learn how to frame insights for different stakeholders (Tech & Non-Tech)
โ Use data storytellingโsimplify complex findings into actionable takeaways
๐ก Example: Instead of saying, "Revenue increased by 12%," say "Revenue increased 12% after launching a targeted discount campaign, driving a 20% increase in repeat purchases."
๐น 3๏ธโฃ ๐๐จ๐ฐ๐๐ซ ๐๐ / ๐๐๐๐ฅ๐๐๐ฎโ๐๐๐ค๐ ๐๐๐ฌ๐ก๐๐จ๐๐ซ๐๐ฌ ๐๐ก๐๐ญ ๐๐ฉ๐๐๐ค!
โ Avoid overloading dashboards with too many visualsโfocus on key KPIs
โ Use interactive elements (filters, drill-throughs) for better usability
โ Keep visuals simple & clearโbar charts are better than complex pie charts!
๐ก Tip: Before creating a dashboard, ask: "What business problem does this solve?"
๐น 4๏ธโฃ ๐๐ฒ๐ญ๐ก๐จ๐ง & ๐๐ฑ๐๐๐ฅโ๐๐๐ง๐๐ฅ๐ ๐๐๐ญ๐ ๐๐๐๐ข๐๐ข๐๐ง๐ญ๐ฅ๐ฒ
โ Python for data wrangling, EDA & automation (Pandas, NumPy, Seaborn)
โ Excel for quick analysis, PivotTables, VLOOKUP/XLOOKUP, Power Query
โ Know when to use Excel vs. Python (hint: small vs. large datasets)
Being a Data Analyst is more than just running queriesโitโs about understanding the business, making insights actionable, and communicating effectively!
Free Resources: https://t.me/sqlspecialist
โค4
๐ ๐๐ถ๐๐ฐ๐ผ ๐๐ฅ๐๐ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐๐ฟ๐๐ฒ๐ | ๐ฑ ๐ ๐๐๐-๐๐ผ ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
๐ 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
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
โค10
๐ SQL Project Series #18
Hotel Booking Analytics ๐จ
Analyze hotel bookings, guests, rooms, payments, and occupancy trends using SQL to improve revenue, customer satisfaction, and operational efficiency.
๐ฏ Business Objectives
โ Track hotel bookings
โ Monitor room occupancy
โ Analyze guest demographics
โ Measure booking cancellations
โ Evaluate room performance
โ Analyze revenue trends
โ Optimize pricing strategy
โ Build hotel management dashboards
๐ Step 1: Create Database
CREATE DATABASE hotel_booking_db;
USE hotel_booking_db;
๐ Step 2: Create Guests Table
CREATE TABLE guests (
guest_id INT PRIMARY KEY,
guest_name VARCHAR(100),
gender VARCHAR(10),
city VARCHAR(50),
check_in_date DATE,
check_out_date DATE
);
๐ Step 3: Create Rooms Table
CREATE TABLE rooms (
room_id INT PRIMARY KEY,
room_type VARCHAR(50),
room_price DECIMAL(10,2),
room_status VARCHAR(20)
);
๐ Step 4: Create Bookings Table
CREATE TABLE bookings (
booking_id INT PRIMARY KEY,
guest_id INT,
room_id INT,
booking_date DATE,
booking_status VARCHAR(20),
payment_amount DECIMAL(10,2),
FOREIGN KEY (guest_id) REFERENCES guests(guest_id),
FOREIGN KEY (room_id) REFERENCES rooms(room_id)
);
๐ Step 5: Insert Sample Guests
INSERT INTO guests VALUES
(1,'Rahul Sharma','Male','Mumbai','2025-01-10','2025-01-13'),
(2,'Priya Verma','Female','Delhi','2025-01-12','2025-01-15'),
(3,'Amit Patel','Male','Pune','2025-01-14','2025-01-16'),
(4,'Sneha Joshi','Female','Bangalore','2025-01-15','2025-01-18'),
(5,'Rohan Gupta','Male','Hyderabad','2025-01-18','2025-01-20');
๐ Step 6: Insert Sample Rooms
INSERT INTO rooms VALUES
(101,'Standard',3000,'Occupied'),
(102,'Deluxe',5000,'Available'),
(103,'Suite',8500,'Occupied'),
(104,'Standard',3000,'Available'),
(105,'Deluxe',5000,'Occupied');
๐ Step 7: Insert Sample Bookings
INSERT INTO bookings VALUES
(1001,1,101,'2025-01-05','Confirmed',9000),
(1002,2,102,'2025-01-06','Confirmed',15000),
(1003,3,103,'2025-01-07','Cancelled',0),
(1004,4,104,'2025-01-08','Confirmed',9000),
(1005,5,105,'2025-01-10','Confirmed',10000);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ Joins
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
โ Ranking Functions
๐ Business KPIs You Can Build
๐ Total Bookings
๐ Confirmed Bookings
๐ Cancelled Bookings
๐ Booking Cancellation Rate
๐ Total Revenue
๐ Average Booking Value
๐ Average Length of Stay
๐ Occupancy Rate
๐ Revenue by Room Type
๐ Revenue by Month
๐ Room Utilization
๐ Available vs Occupied Rooms
๐ Most Popular Room Type
๐ Guest Retention Rate
๐ Repeat Guests
๐ Peak Booking Days
๐ Seasonal Booking Trends
๐ City-wise Guest Distribution
๐ Customer Lifetime Value
๐ Executive Hotel Dashboard
๐ฏ This project reflects real-world SQL analysis performed by Hotel Revenue Analysts, Hospitality Analysts, Operations teams, and Business Intelligence professionals to optimize occupancy, pricing, and customer experience.
๐ก Double Tap โค๏ธ For More
Hotel Booking Analytics ๐จ
Analyze hotel bookings, guests, rooms, payments, and occupancy trends using SQL to improve revenue, customer satisfaction, and operational efficiency.
๐ฏ Business Objectives
โ Track hotel bookings
โ Monitor room occupancy
โ Analyze guest demographics
โ Measure booking cancellations
โ Evaluate room performance
โ Analyze revenue trends
โ Optimize pricing strategy
โ Build hotel management dashboards
๐ Step 1: Create Database
CREATE DATABASE hotel_booking_db;
USE hotel_booking_db;
๐ Step 2: Create Guests Table
CREATE TABLE guests (
guest_id INT PRIMARY KEY,
guest_name VARCHAR(100),
gender VARCHAR(10),
city VARCHAR(50),
check_in_date DATE,
check_out_date DATE
);
๐ Step 3: Create Rooms Table
CREATE TABLE rooms (
room_id INT PRIMARY KEY,
room_type VARCHAR(50),
room_price DECIMAL(10,2),
room_status VARCHAR(20)
);
๐ Step 4: Create Bookings Table
CREATE TABLE bookings (
booking_id INT PRIMARY KEY,
guest_id INT,
room_id INT,
booking_date DATE,
booking_status VARCHAR(20),
payment_amount DECIMAL(10,2),
FOREIGN KEY (guest_id) REFERENCES guests(guest_id),
FOREIGN KEY (room_id) REFERENCES rooms(room_id)
);
๐ Step 5: Insert Sample Guests
INSERT INTO guests VALUES
(1,'Rahul Sharma','Male','Mumbai','2025-01-10','2025-01-13'),
(2,'Priya Verma','Female','Delhi','2025-01-12','2025-01-15'),
(3,'Amit Patel','Male','Pune','2025-01-14','2025-01-16'),
(4,'Sneha Joshi','Female','Bangalore','2025-01-15','2025-01-18'),
(5,'Rohan Gupta','Male','Hyderabad','2025-01-18','2025-01-20');
๐ Step 6: Insert Sample Rooms
INSERT INTO rooms VALUES
(101,'Standard',3000,'Occupied'),
(102,'Deluxe',5000,'Available'),
(103,'Suite',8500,'Occupied'),
(104,'Standard',3000,'Available'),
(105,'Deluxe',5000,'Occupied');
๐ Step 7: Insert Sample Bookings
INSERT INTO bookings VALUES
(1001,1,101,'2025-01-05','Confirmed',9000),
(1002,2,102,'2025-01-06','Confirmed',15000),
(1003,3,103,'2025-01-07','Cancelled',0),
(1004,4,104,'2025-01-08','Confirmed',9000),
(1005,5,105,'2025-01-10','Confirmed',10000);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ Joins
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
โ Ranking Functions
๐ Business KPIs You Can Build
๐ Total Bookings
๐ Confirmed Bookings
๐ Cancelled Bookings
๐ Booking Cancellation Rate
๐ Total Revenue
๐ Average Booking Value
๐ Average Length of Stay
๐ Occupancy Rate
๐ Revenue by Room Type
๐ Revenue by Month
๐ Room Utilization
๐ Available vs Occupied Rooms
๐ Most Popular Room Type
๐ Guest Retention Rate
๐ Repeat Guests
๐ Peak Booking Days
๐ Seasonal Booking Trends
๐ City-wise Guest Distribution
๐ Customer Lifetime Value
๐ Executive Hotel Dashboard
๐ฏ This project reflects real-world SQL analysis performed by Hotel Revenue Analysts, Hospitality Analysts, Operations teams, and Business Intelligence professionals to optimize occupancy, pricing, and customer experience.
๐ก Double Tap โค๏ธ For More
โค6
๐๐ & ๐๐ฎ๐๐ฎ ๐ฆ๐ฐ๐ถ๐ฒ๐ป๐ฐ๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ (๐ก๐ผ ๐๐ผ๐ฑ๐ถ๐ป๐ด ๐ก๐ฒ๐ฒ๐ฑ๐ฒ๐ฑ)
Apply Now๐:- https://pdlink.in/4aYWald
By E&ICT Academy, IIT Roorkee
Batch Closing Soon - 26th July 2026
Apply Now๐:- https://pdlink.in/4aYWald
By E&ICT Academy, IIT Roorkee
Batch Closing Soon - 26th July 2026
โค1
๐ SQL Project Series #18
Hotel Booking Analytics ๐จ
Analyze hotel bookings, guests, rooms, payments, and occupancy trends using SQL to improve revenue, customer satisfaction, and operational efficiency.
๐ฏ Business Objectives
โ Track hotel bookings
โ Monitor room occupancy
โ Analyze guest demographics
โ Measure booking cancellations
โ Evaluate room performance
โ Analyze revenue trends
โ Optimize pricing strategy
โ Build hotel management dashboards
๐ Step 1: Create Database
CREATE DATABASE hotel_booking_db;
USE hotel_booking_db;
๐ Step 2: Create Guests Table
CREATE TABLE guests (
guest_id INT PRIMARY KEY,
guest_name VARCHAR(100),
gender VARCHAR(10),
city VARCHAR(50),
check_in_date DATE,
check_out_date DATE
);
๐ Step 3: Create Rooms Table
CREATE TABLE rooms (
room_id INT PRIMARY KEY,
room_type VARCHAR(50),
room_price DECIMAL(10,2),
room_status VARCHAR(20)
);
๐ Step 4: Create Bookings Table
CREATE TABLE bookings (
booking_id INT PRIMARY KEY,
guest_id INT,
room_id INT,
booking_date DATE,
booking_status VARCHAR(20),
payment_amount DECIMAL(10,2),
FOREIGN KEY (guest_id) REFERENCES guests(guest_id),
FOREIGN KEY (room_id) REFERENCES rooms(room_id)
);
๐ Step 5: Insert Sample Guests
INSERT INTO guests VALUES
(1,'Rahul Sharma','Male','Mumbai','2025-01-10','2025-01-13'),
(2,'Priya Verma','Female','Delhi','2025-01-12','2025-01-15'),
(3,'Amit Patel','Male','Pune','2025-01-14','2025-01-16'),
(4,'Sneha Joshi','Female','Bangalore','2025-01-15','2025-01-18'),
(5,'Rohan Gupta','Male','Hyderabad','2025-01-18','2025-01-20');
๐ Step 6: Insert Sample Rooms
INSERT INTO rooms VALUES
(101,'Standard',3000,'Occupied'),
(102,'Deluxe',5000,'Available'),
(103,'Suite',8500,'Occupied'),
(104,'Standard',3000,'Available'),
(105,'Deluxe',5000,'Occupied');
๐ Step 7: Insert Sample Bookings
INSERT INTO bookings VALUES
(1001,1,101,'2025-01-05','Confirmed',9000),
(1002,2,102,'2025-01-06','Confirmed',15000),
(1003,3,103,'2025-01-07','Cancelled',0),
(1004,4,104,'2025-01-08','Confirmed',9000),
(1005,5,105,'2025-01-10','Confirmed',10000);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ Joins
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
โ Ranking Functions
๐ Business KPIs You Can Build
๐ Total Bookings
๐ Confirmed Bookings
๐ Cancelled Bookings
๐ Booking Cancellation Rate
๐ Total Revenue
๐ Average Booking Value
๐ Average Length of Stay
๐ Occupancy Rate
๐ Revenue by Room Type
๐ Revenue by Month
๐ Room Utilization
๐ Available vs Occupied Rooms
๐ Most Popular Room Type
๐ Guest Retention Rate
๐ Repeat Guests
๐ Peak Booking Days
๐ Seasonal Booking Trends
๐ City-wise Guest Distribution
๐ Customer Lifetime Value
๐ Executive Hotel Dashboard
๐ฏ This project reflects real-world SQL analysis performed by Hotel Revenue Analysts, Hospitality Analysts, Operations teams, and Business Intelligence professionals to optimize occupancy, pricing, and customer experience.
๐ก Double Tap โค๏ธ For More
Hotel Booking Analytics ๐จ
Analyze hotel bookings, guests, rooms, payments, and occupancy trends using SQL to improve revenue, customer satisfaction, and operational efficiency.
๐ฏ Business Objectives
โ Track hotel bookings
โ Monitor room occupancy
โ Analyze guest demographics
โ Measure booking cancellations
โ Evaluate room performance
โ Analyze revenue trends
โ Optimize pricing strategy
โ Build hotel management dashboards
๐ Step 1: Create Database
CREATE DATABASE hotel_booking_db;
USE hotel_booking_db;
๐ Step 2: Create Guests Table
CREATE TABLE guests (
guest_id INT PRIMARY KEY,
guest_name VARCHAR(100),
gender VARCHAR(10),
city VARCHAR(50),
check_in_date DATE,
check_out_date DATE
);
๐ Step 3: Create Rooms Table
CREATE TABLE rooms (
room_id INT PRIMARY KEY,
room_type VARCHAR(50),
room_price DECIMAL(10,2),
room_status VARCHAR(20)
);
๐ Step 4: Create Bookings Table
CREATE TABLE bookings (
booking_id INT PRIMARY KEY,
guest_id INT,
room_id INT,
booking_date DATE,
booking_status VARCHAR(20),
payment_amount DECIMAL(10,2),
FOREIGN KEY (guest_id) REFERENCES guests(guest_id),
FOREIGN KEY (room_id) REFERENCES rooms(room_id)
);
๐ Step 5: Insert Sample Guests
INSERT INTO guests VALUES
(1,'Rahul Sharma','Male','Mumbai','2025-01-10','2025-01-13'),
(2,'Priya Verma','Female','Delhi','2025-01-12','2025-01-15'),
(3,'Amit Patel','Male','Pune','2025-01-14','2025-01-16'),
(4,'Sneha Joshi','Female','Bangalore','2025-01-15','2025-01-18'),
(5,'Rohan Gupta','Male','Hyderabad','2025-01-18','2025-01-20');
๐ Step 6: Insert Sample Rooms
INSERT INTO rooms VALUES
(101,'Standard',3000,'Occupied'),
(102,'Deluxe',5000,'Available'),
(103,'Suite',8500,'Occupied'),
(104,'Standard',3000,'Available'),
(105,'Deluxe',5000,'Occupied');
๐ Step 7: Insert Sample Bookings
INSERT INTO bookings VALUES
(1001,1,101,'2025-01-05','Confirmed',9000),
(1002,2,102,'2025-01-06','Confirmed',15000),
(1003,3,103,'2025-01-07','Cancelled',0),
(1004,4,104,'2025-01-08','Confirmed',9000),
(1005,5,105,'2025-01-10','Confirmed',10000);
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ Joins
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
โ Ranking Functions
๐ Business KPIs You Can Build
๐ Total Bookings
๐ Confirmed Bookings
๐ Cancelled Bookings
๐ Booking Cancellation Rate
๐ Total Revenue
๐ Average Booking Value
๐ Average Length of Stay
๐ Occupancy Rate
๐ Revenue by Room Type
๐ Revenue by Month
๐ Room Utilization
๐ Available vs Occupied Rooms
๐ Most Popular Room Type
๐ Guest Retention Rate
๐ Repeat Guests
๐ Peak Booking Days
๐ Seasonal Booking Trends
๐ City-wise Guest Distribution
๐ Customer Lifetime Value
๐ Executive Hotel Dashboard
๐ฏ This project reflects real-world SQL analysis performed by Hotel Revenue Analysts, Hospitality Analysts, Operations teams, and Business Intelligence professionals to optimize occupancy, pricing, and customer experience.
๐ก Double Tap โค๏ธ For More
โค9
๐ ๐๐ถ๐๐ฐ๐ผ ๐๐ฅ๐๐ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐๐ฟ๐๐ฒ๐ | ๐ฑ ๐ ๐๐๐-๐๐ผ ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
Cisco offers learning opportunities covering some of the most valuable foundations for careers in Cybersecurity, Networking, Linux and IoT.
โ Beginner-Friendly Tech Skills
โ Learn In-Demand IT Concepts
โ Build Practical Knowledge
โ Strengthen Your Resume
โ Great for Students & Freshers
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4fhCSKo
๐ฅ Learn from Cisco โข Build Skills โข Upgrade Your Resume โข Get Career-Ready!
โค2
๐ ๐๐๐๐๐ง๐ญ๐ฎ๐ซ๐ ๐
๐๐๐ ๐๐๐ซ๐ญ๐ข๐๐ข๐๐๐ญ๐ข๐จ๐ง ๐๐จ๐ฎ๐ซ๐ฌ๐๐ฌ ๐
Boost your skills with 100% FREE certification courses from Accenture!
๐ FREE Courses Offered:
1๏ธโฃ Data Processing and Visualization
2๏ธโฃ Exploratory Data Analysis
3๏ธโฃ SQL Fundamentals
4๏ธโฃ Python Basics
5๏ธโฃ Acquiring Data
๐๐ข๐ง๐ค ๐:-
https://pdlink.in/4hfxyIX
โ Learn Online | ๐ Get Certified
Boost your skills with 100% FREE certification courses from Accenture!
๐ FREE Courses Offered:
1๏ธโฃ Data Processing and Visualization
2๏ธโฃ Exploratory Data Analysis
3๏ธโฃ SQL Fundamentals
4๏ธโฃ Python Basics
5๏ธโฃ Acquiring Data
๐๐ข๐ง๐ค ๐:-
https://pdlink.in/4hfxyIX
โ Learn Online | ๐ Get Certified
โ
SQL Interview Questions with Answers
1. What is a window function?
A window function computes results over a group ("window") of rows related to the current row, without collapsing them (like GROUP BY).
Examples: ROW_NUMBER(), RANK(), SUM() OVER(...) for running totals, rankings, or moving averages.
2. What is the difference between RANK() and ROW_NUMBER()?
โข ROW_NUMBER(): assigns unique sequential numbers to all rows, even if values are equal.
โข RANK(): gives same rank to tied values, then skips the next rank (e.g., 1, 1, 3).
3. How do you find the second highest salary?
SELECT salary
FROM (
SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) as rnk
FROM employees
) t
WHERE rnk = 2;
This avoids ties if you want exactly the secondโhighest value.
4. What is a recursive CTE?
A recursive CTE refers to itself in its WITH definition, usually in the form "anchor + UNION ALL recursive step". It is used for hierarchical data like managersโemployees, org charts, or tree structures.
5. What is the difference between correlated and non-correlated subquery?
โข Nonโcorrelated: runs once, independent of the outer query.
โข Correlated: references columns from the outer query and runs once per outer row (e.g., SELECT ... FROM t1 WHERE col > (SELECT AVG(col) FROM t2 WHERE t2.id = t1.id)).
6. How do you remove duplicates without DISTINCT?
Use window functions:
DELETE FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY id) as rn
FROM table
) t
WHERE rn > 1;
Or use GROUP BY and keep one row per group.
7. What is an INDEX and when do you use it?
An index speeds up data retrieval on specified columns (used in WHERE, JOIN, ORDER BY). Use it on columns that are frequently filtered or joined; avoid on very small tables or columns updated often.
8. Explain self-join with example.
A selfโjoin joins a table to itself using aliases. Example:
SELECT e1.name as employee, e2.name as manager
FROM employees e1
LEFT JOIN employees e2 ON e1.manager_id = e2.id;
Useful for parentโchild relationships.
9. What is the difference between DELETE, DROP, and TRUNCATE?
โข DELETE: removes rows (can be filtered by WHERE), can be rolled back.
โข TRUNCATE: removes all rows quickly, resets storage; often not logged per row.
โข DROP: removes entire table (structure + data); cannot be rolled back.
10. How do you pivot/unpivot data in SQL?
โข Pivot: turns rows into columns (e.g., sales per month as columns) using PIVOT or conditional aggregation (MAX(CASE WHEN ... END)).
โข Unpivot: turns columns into rows (e.g., multiple month columns โ one month column) using UNPIVOT or UNION ALL/VALUES.
11. What is LAG() and LEAD()?
โข LAG(col, n): value of col from n rows before current row.
โข LEAD(col, n): value from n rows after. Used for timeโseries analysis (MoM change, prior/next values).
12. How do you handle NULL in aggregates?
Most aggregates (SUM, AVG, MAX, MIN) ignore NULL.
โข COUNT(col) ignores NULL; COUNT(*) counts all rows.
โข Use COALESCE() or ISNULL() to replace NULL before aggregating.
13. What is the difference between VIEW and MATERIALIZED VIEW?
โข VIEW: virtual table; query runs every time you select.
โข MATERIALIZED VIEW: stores result physically and refreshes periodically; faster reads, slower updates.
14. Explain ACID properties.
โข Atomicity: transaction is "all or nothing".
โข Consistency: valid state before and after.
โข Isolation: concurrent transactions don't interfere.
โข Durability: committed changes survive crashes.
15. How do you optimize a slow query?
โข Add proper indexes on WHERE, JOIN, ORDER BY columns.
โข Remove unnecessary SELECT *, DISTINCT, or functions on indexed columns.
โข Check execution plan and avoid large scans; use LIMIT or partitioning if possible.
16. What is the difference between INNER JOIN and EXISTS?
โข INNER JOIN: returns combined columns from both tables where keys match.
โข EXISTS: checks if a subquery returns any rows; usually faster when you only care about existence (e.g., filtering with WHERE EXISTS).
1. What is a window function?
A window function computes results over a group ("window") of rows related to the current row, without collapsing them (like GROUP BY).
Examples: ROW_NUMBER(), RANK(), SUM() OVER(...) for running totals, rankings, or moving averages.
2. What is the difference between RANK() and ROW_NUMBER()?
โข ROW_NUMBER(): assigns unique sequential numbers to all rows, even if values are equal.
โข RANK(): gives same rank to tied values, then skips the next rank (e.g., 1, 1, 3).
3. How do you find the second highest salary?
SELECT salary
FROM (
SELECT salary, DENSE_RANK() OVER (ORDER BY salary DESC) as rnk
FROM employees
) t
WHERE rnk = 2;
This avoids ties if you want exactly the secondโhighest value.
4. What is a recursive CTE?
A recursive CTE refers to itself in its WITH definition, usually in the form "anchor + UNION ALL recursive step". It is used for hierarchical data like managersโemployees, org charts, or tree structures.
5. What is the difference between correlated and non-correlated subquery?
โข Nonโcorrelated: runs once, independent of the outer query.
โข Correlated: references columns from the outer query and runs once per outer row (e.g., SELECT ... FROM t1 WHERE col > (SELECT AVG(col) FROM t2 WHERE t2.id = t1.id)).
6. How do you remove duplicates without DISTINCT?
Use window functions:
DELETE FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY id) as rn
FROM table
) t
WHERE rn > 1;
Or use GROUP BY and keep one row per group.
7. What is an INDEX and when do you use it?
An index speeds up data retrieval on specified columns (used in WHERE, JOIN, ORDER BY). Use it on columns that are frequently filtered or joined; avoid on very small tables or columns updated often.
8. Explain self-join with example.
A selfโjoin joins a table to itself using aliases. Example:
SELECT e1.name as employee, e2.name as manager
FROM employees e1
LEFT JOIN employees e2 ON e1.manager_id = e2.id;
Useful for parentโchild relationships.
9. What is the difference between DELETE, DROP, and TRUNCATE?
โข DELETE: removes rows (can be filtered by WHERE), can be rolled back.
โข TRUNCATE: removes all rows quickly, resets storage; often not logged per row.
โข DROP: removes entire table (structure + data); cannot be rolled back.
10. How do you pivot/unpivot data in SQL?
โข Pivot: turns rows into columns (e.g., sales per month as columns) using PIVOT or conditional aggregation (MAX(CASE WHEN ... END)).
โข Unpivot: turns columns into rows (e.g., multiple month columns โ one month column) using UNPIVOT or UNION ALL/VALUES.
11. What is LAG() and LEAD()?
โข LAG(col, n): value of col from n rows before current row.
โข LEAD(col, n): value from n rows after. Used for timeโseries analysis (MoM change, prior/next values).
12. How do you handle NULL in aggregates?
Most aggregates (SUM, AVG, MAX, MIN) ignore NULL.
โข COUNT(col) ignores NULL; COUNT(*) counts all rows.
โข Use COALESCE() or ISNULL() to replace NULL before aggregating.
13. What is the difference between VIEW and MATERIALIZED VIEW?
โข VIEW: virtual table; query runs every time you select.
โข MATERIALIZED VIEW: stores result physically and refreshes periodically; faster reads, slower updates.
14. Explain ACID properties.
โข Atomicity: transaction is "all or nothing".
โข Consistency: valid state before and after.
โข Isolation: concurrent transactions don't interfere.
โข Durability: committed changes survive crashes.
15. How do you optimize a slow query?
โข Add proper indexes on WHERE, JOIN, ORDER BY columns.
โข Remove unnecessary SELECT *, DISTINCT, or functions on indexed columns.
โข Check execution plan and avoid large scans; use LIMIT or partitioning if possible.
16. What is the difference between INNER JOIN and EXISTS?
โข INNER JOIN: returns combined columns from both tables where keys match.
โข EXISTS: checks if a subquery returns any rows; usually faster when you only care about existence (e.g., filtering with WHERE EXISTS).
โค4๐1
๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐ฆ๐ค๐ ๐๐ผ๐ฟ ๐๐ฅ๐๐! ๐๏ธ๐ป
Start learning SQL with these 100% FREE resources and build one of the most in-demand skills in tech!
โ Beginner-Friendly SQL Tutorials
โ FREE Online SQL Courses
โ Interactive SQL Practice Platforms
โ Real-World Database Projects
โ Interview Preparation Resources
โ Hands-on Exercises & Challenges
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4yLrNci
๐ Start your SQL journey today and unlock exciting career opportunities!
Start learning SQL with these 100% FREE resources and build one of the most in-demand skills in tech!
โ Beginner-Friendly SQL Tutorials
โ FREE Online SQL Courses
โ Interactive SQL Practice Platforms
โ Real-World Database Projects
โ Interview Preparation Resources
โ Hands-on Exercises & Challenges
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/4yLrNci
๐ Start your SQL journey today and unlock exciting career opportunities!
โค1
Majority of top companies hiring for analytic roles (Data Analyst/Business Analyst) focus heavily on SQL understanding as a selection criteria, which according to me, should be the first thing you start your preparation with.
I have divided this SQL roadmap into 3 steps (Basics, Level Up & Practice), and it should take around 1 month to complete.
Step 1 - Basics ๐ข :
โกWhat is a Relational Database / RDBMS?
โกSQL Data Types - Varchar, text, int, number, date, float, boolean.
โกSQL commands - select, where, like, distinct, between, group by, having, order by, insert into, case when, update, truncate, delete, commit, rollback (basically all the DDL, DML, DCL, TCL commands in SQL).
โกIntegrity Constraints - Primary key, foreign key, not null, unique.
โกOperators arithmetic, logical, and comparison operations.
โกUse of distinct, order by, limit, and top.
โกUse of union and union all.
โกJoins in SQL inner, left, right, outer, self, full outer, cross join.
Step 2 - Level up โฌโฌ :
โกNormalization in SQL
โกAggregate, date, and string functions
โกSub-Queries
โกCTE table / with clause
โกIn-built SQL functions
โกWindow functions
โกViews
Step 3 - Practice SQL Questions on leetcode & hackerrank โ
Hope it helps :)
I have divided this SQL roadmap into 3 steps (Basics, Level Up & Practice), and it should take around 1 month to complete.
Step 1 - Basics ๐ข :
โกWhat is a Relational Database / RDBMS?
โกSQL Data Types - Varchar, text, int, number, date, float, boolean.
โกSQL commands - select, where, like, distinct, between, group by, having, order by, insert into, case when, update, truncate, delete, commit, rollback (basically all the DDL, DML, DCL, TCL commands in SQL).
โกIntegrity Constraints - Primary key, foreign key, not null, unique.
โกOperators arithmetic, logical, and comparison operations.
โกUse of distinct, order by, limit, and top.
โกUse of union and union all.
โกJoins in SQL inner, left, right, outer, self, full outer, cross join.
Step 2 - Level up โฌโฌ :
โกNormalization in SQL
โกAggregate, date, and string functions
โกSub-Queries
โกCTE table / with clause
โกIn-built SQL functions
โกWindow functions
โกViews
Step 3 - Practice SQL Questions on leetcode & hackerrank โ
Hope it helps :)
โค4
๐ ๐๐๐ฏ๐ฒ๐ฟ๐๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ & ๐๐น๐ผ๐๐ฑ ๐๐ผ๐บ๐ฝ๐๐๐ถ๐ป๐ด ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐
Build job-ready skills in two of the most in-demand technology fields and strengthen your rรฉsumรฉ with valuable certifications! ๐
๐ Cyber Security :- https://pdlink.in/4bHIF9K
โ
โ๏ธ Cloud Computing :- https://pdlink.in/4yXs8bU
โ
Perfect for Students, Freshers & Working Professionals looking to launch or upgrade their tech careers. ๐ผ
๐ Enroll for FREE & Get Certified
Build job-ready skills in two of the most in-demand technology fields and strengthen your rรฉsumรฉ with valuable certifications! ๐
๐ Cyber Security :- https://pdlink.in/4bHIF9K
โ
โ๏ธ Cloud Computing :- https://pdlink.in/4yXs8bU
โ
Perfect for Students, Freshers & Working Professionals looking to launch or upgrade their tech careers. ๐ผ
๐ Enroll for FREE & Get Certified
๐ SQL Project Series #19
Logistics & Shipment Analytics ๐ฆ
Analyze shipments, warehouses, delivery performance, customers, and transportation data using SQL to optimize supply chain operations and improve delivery efficiency.
๐ฏ Business Objectives
โ Track shipments
โ Monitor delivery performance
โ Analyze warehouse operations
โ Measure transportation efficiency
โ Identify delayed deliveries
โ Optimize shipping costs
โ Analyze customer orders
โ Build logistics dashboards
๐ Step 1: Create Database
CREATE DATABASE logistics_db;
USE logistics_db;
๐ Step 2: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
city VARCHAR(50)
);
๐ Step 3: Create Warehouses Table
CREATE TABLE warehouses (
warehouse_id INT PRIMARY KEY,
warehouse_name VARCHAR(100),
city VARCHAR(50)
);
๐ Step 4: Create Shipments Table
CREATE TABLE shipments (
shipment_id INT PRIMARY KEY,
customer_id INT,
warehouse_id INT,
shipment_date DATE,
delivery_date DATE,
shipping_cost DECIMAL(10,2),
shipment_status VARCHAR(30),
delivery_partner VARCHAR(100),
FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
FOREIGN KEY (warehouse_id) REFERENCES warehouses(warehouse_id)
);
๐ Step 5: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Mumbai'),
(2,'Priya Verma','Delhi'),
(3,'Amit Patel','Pune'),
(4,'Sneha Joshi','Bangalore'),
(5,'Rohan Gupta','Hyderabad');
๐ Step 6: Insert Sample Warehouses
INSERT INTO warehouses VALUES
(101,'Mumbai Warehouse','Mumbai'),
(102,'Delhi Warehouse','Delhi'),
(103,'Pune Warehouse','Pune'),
(104,'Bangalore Warehouse','Bangalore');
๐ Step 7: Insert Sample Shipments
INSERT INTO shipments VALUES
(1001,1,101,'2025-01-05','2025-01-07',450,'Delivered','BlueDart'),
(1002,2,102,'2025-01-06','2025-01-09',620,'Delivered','DTDC'),
(1003,3,103,'2025-01-07','2025-01-11',780,'Delayed','Delhivery'),
(1004,4,104,'2025-01-08','2025-01-10',390,'Delivered','XpressBees'),
(1005,5,101,'2025-01-09','2025-01-14',950,'Delayed','BlueDart');
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ INNER JOIN
โ LEFT JOIN
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
โ Ranking Functions
๐ Business KPIs You Can Build
๐ Total Shipments
๐ Delivered Shipments
๐ Delayed Shipments
๐ Delivery Success Rate
๐ Average Delivery Time
๐ Total Shipping Cost
๐ Shipping Cost by Warehouse
๐ Shipping Cost by Delivery Partner
๐ Shipments by City
๐ Shipments by Warehouse
๐ Delivery Partner Performance
๐ Average Delivery Time by Partner
๐ Warehouse Utilization
๐ Peak Shipment Days
๐ Monthly Shipment Trend
๐ Customer-wise Shipments
๐ On-Time Delivery Rate
๐ Delayed Delivery Analysis
๐ Cost per Shipment
๐ Executive Logistics Dashboard
๐ฏ This project reflects real-world SQL analysis
Performed by Supply Chain Analysts, Logistics Analysts, Operations Analysts, and Business Intelligence professionals at e-commerce, courier, manufacturing, and retail companies to optimize delivery performance, reduce costs, and improve customer satisfaction.
๐ก Double Tap โค๏ธ For More
Logistics & Shipment Analytics ๐ฆ
Analyze shipments, warehouses, delivery performance, customers, and transportation data using SQL to optimize supply chain operations and improve delivery efficiency.
๐ฏ Business Objectives
โ Track shipments
โ Monitor delivery performance
โ Analyze warehouse operations
โ Measure transportation efficiency
โ Identify delayed deliveries
โ Optimize shipping costs
โ Analyze customer orders
โ Build logistics dashboards
๐ Step 1: Create Database
CREATE DATABASE logistics_db;
USE logistics_db;
๐ Step 2: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
city VARCHAR(50)
);
๐ Step 3: Create Warehouses Table
CREATE TABLE warehouses (
warehouse_id INT PRIMARY KEY,
warehouse_name VARCHAR(100),
city VARCHAR(50)
);
๐ Step 4: Create Shipments Table
CREATE TABLE shipments (
shipment_id INT PRIMARY KEY,
customer_id INT,
warehouse_id INT,
shipment_date DATE,
delivery_date DATE,
shipping_cost DECIMAL(10,2),
shipment_status VARCHAR(30),
delivery_partner VARCHAR(100),
FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
FOREIGN KEY (warehouse_id) REFERENCES warehouses(warehouse_id)
);
๐ Step 5: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Mumbai'),
(2,'Priya Verma','Delhi'),
(3,'Amit Patel','Pune'),
(4,'Sneha Joshi','Bangalore'),
(5,'Rohan Gupta','Hyderabad');
๐ Step 6: Insert Sample Warehouses
INSERT INTO warehouses VALUES
(101,'Mumbai Warehouse','Mumbai'),
(102,'Delhi Warehouse','Delhi'),
(103,'Pune Warehouse','Pune'),
(104,'Bangalore Warehouse','Bangalore');
๐ Step 7: Insert Sample Shipments
INSERT INTO shipments VALUES
(1001,1,101,'2025-01-05','2025-01-07',450,'Delivered','BlueDart'),
(1002,2,102,'2025-01-06','2025-01-09',620,'Delivered','DTDC'),
(1003,3,103,'2025-01-07','2025-01-11',780,'Delayed','Delhivery'),
(1004,4,104,'2025-01-08','2025-01-10',390,'Delivered','XpressBees'),
(1005,5,101,'2025-01-09','2025-01-14',950,'Delayed','BlueDart');
๐ง SQL Concepts You'll Practice
โ DDL & DML
โ INNER JOIN
โ LEFT JOIN
โ Aggregate Functions
โ GROUP BY
โ HAVING
โ CASE WHEN
โ Date Functions
โ CTEs
โ Window Functions
โ Ranking Functions
๐ Business KPIs You Can Build
๐ Total Shipments
๐ Delivered Shipments
๐ Delayed Shipments
๐ Delivery Success Rate
๐ Average Delivery Time
๐ Total Shipping Cost
๐ Shipping Cost by Warehouse
๐ Shipping Cost by Delivery Partner
๐ Shipments by City
๐ Shipments by Warehouse
๐ Delivery Partner Performance
๐ Average Delivery Time by Partner
๐ Warehouse Utilization
๐ Peak Shipment Days
๐ Monthly Shipment Trend
๐ Customer-wise Shipments
๐ On-Time Delivery Rate
๐ Delayed Delivery Analysis
๐ Cost per Shipment
๐ Executive Logistics Dashboard
๐ฏ This project reflects real-world SQL analysis
Performed by Supply Chain Analysts, Logistics Analysts, Operations Analysts, and Business Intelligence professionals at e-commerce, courier, manufacturing, and retail companies to optimize delivery performance, reduce costs, and improve customer satisfaction.
๐ก Double Tap โค๏ธ For More