✅ Complete SQL Roadmap in 2 Months
Month 1: Strong SQL Foundations
Week 1: Database and query basics
• What SQL does in analytics and business
• Tables, rows, columns
• Primary key and foreign key
• SELECT, DISTINCT
• WHERE with AND, OR, IN, BETWEEN
Outcome: You understand data structure and fetch filtered data.
Week 2: Sorting and aggregation
• ORDER BY and LIMIT
• COUNT, SUM, AVG, MIN, MAX
• GROUP BY
• HAVING vs WHERE
• Use case like total sales per product
Outcome: You summarize data clearly.
Week 3: Joins fundamentals
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• Join conditions
• Handling NULL values
Outcome: You combine multiple tables correctly.
Week 4: Joins practice and cleanup
• Duplicate rows after joins
• SELF JOIN with examples
• Data cleaning using SQL
• Daily join-based questions
Outcome: You stop making join mistakes.
Month 2: Analytics-Level SQL
Week 5: Subqueries and CTEs
• Subqueries in WHERE and SELECT
• Correlated subqueries
• Common Table Expressions
• Readability and reuse
Outcome: You write structured queries.
Week 6: Window functions
• ROW_NUMBER, RANK, DENSE_RANK
• PARTITION BY and ORDER BY
• Running totals
• Top N per category problems
Outcome: You solve advanced analytics queries.
Week 7: Date and string analysis
• Date functions for daily, monthly analysis
• Year-over-year and month-over-month logic
• String functions for text cleanup
Outcome: You handle real business datasets.
Week 8: Project and interview prep
• Build a SQL project using sales or HR data
• Write KPI queries
• Explain query logic step by step
• Daily interview questions practice
Outcome: You are SQL interview ready.
Practice platforms
• LeetCode SQL
• HackerRank SQL
• Kaggle datasets
Double Tap ♥️ For Detailed Explanation of Each Topic
Month 1: Strong SQL Foundations
Week 1: Database and query basics
• What SQL does in analytics and business
• Tables, rows, columns
• Primary key and foreign key
• SELECT, DISTINCT
• WHERE with AND, OR, IN, BETWEEN
Outcome: You understand data structure and fetch filtered data.
Week 2: Sorting and aggregation
• ORDER BY and LIMIT
• COUNT, SUM, AVG, MIN, MAX
• GROUP BY
• HAVING vs WHERE
• Use case like total sales per product
Outcome: You summarize data clearly.
Week 3: Joins fundamentals
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• Join conditions
• Handling NULL values
Outcome: You combine multiple tables correctly.
Week 4: Joins practice and cleanup
• Duplicate rows after joins
• SELF JOIN with examples
• Data cleaning using SQL
• Daily join-based questions
Outcome: You stop making join mistakes.
Month 2: Analytics-Level SQL
Week 5: Subqueries and CTEs
• Subqueries in WHERE and SELECT
• Correlated subqueries
• Common Table Expressions
• Readability and reuse
Outcome: You write structured queries.
Week 6: Window functions
• ROW_NUMBER, RANK, DENSE_RANK
• PARTITION BY and ORDER BY
• Running totals
• Top N per category problems
Outcome: You solve advanced analytics queries.
Week 7: Date and string analysis
• Date functions for daily, monthly analysis
• Year-over-year and month-over-month logic
• String functions for text cleanup
Outcome: You handle real business datasets.
Week 8: Project and interview prep
• Build a SQL project using sales or HR data
• Write KPI queries
• Explain query logic step by step
• Daily interview questions practice
Outcome: You are SQL interview ready.
Practice platforms
• LeetCode SQL
• HackerRank SQL
• Kaggle datasets
Double Tap ♥️ For Detailed Explanation of Each Topic
❤11
Glad to see the amazing response on SQL roadmap. ❤️
Today, let's start with the first topic of SQL roadmap:
✅ Introduction to SQL
SQL is the language you use to ask questions from data stored in databases. Companies store all important data in databases. Sales. Users. Payments. Inventory. When a manager asks a question, SQL pulls the answer.
What a database is
A database is an organized storage system for data. Think of it as a digital cupboard where each drawer holds related data. Each drawer is called a table.
What a table is
A table looks like an Excel sheet. It has rows and columns. Each table stores one type of data.
Example table: customers
- Columns
- customer_id
- name
- email
- city
- signup_date
- Rows
- Each row represents one customer
- One row equals one real-world record
How rows and columns work together
- Columns define what kind of data you store
- Rows hold actual values
- All rows follow the same column structure
Example row
- customer_id: 101
- name: Rahul
- email: [email protected]
- city: Pune
- signup_date: 2024-03-10
Why structure matters
- Clean structure makes data reliable
- Easy to filter, count, and analyze
- Required for accurate reporting
How SQL interacts with tables
- SQL reads data from tables
- SQL filters rows
- SQL selects columns
- SQL summarizes results
Simple SQL example
You ask the database to show names and cities of customers.
What happens behind the scenes
- Database scans the customers table
- Picks name and city columns
- Returns matching rows
Where you will use this daily
- Pull user lists
- Check sales numbers
- Validate data issues
Double Tap ♥️ For More
Today, let's start with the first topic of SQL roadmap:
✅ Introduction to SQL
SQL is the language you use to ask questions from data stored in databases. Companies store all important data in databases. Sales. Users. Payments. Inventory. When a manager asks a question, SQL pulls the answer.
What a database is
A database is an organized storage system for data. Think of it as a digital cupboard where each drawer holds related data. Each drawer is called a table.
What a table is
A table looks like an Excel sheet. It has rows and columns. Each table stores one type of data.
Example table: customers
- Columns
- customer_id
- name
- city
- signup_date
- Rows
- Each row represents one customer
- One row equals one real-world record
How rows and columns work together
- Columns define what kind of data you store
- Rows hold actual values
- All rows follow the same column structure
Example row
- customer_id: 101
- name: Rahul
- email: [email protected]
- city: Pune
- signup_date: 2024-03-10
Why structure matters
- Clean structure makes data reliable
- Easy to filter, count, and analyze
- Required for accurate reporting
How SQL interacts with tables
- SQL reads data from tables
- SQL filters rows
- SQL selects columns
- SQL summarizes results
Simple SQL example
You ask the database to show names and cities of customers.
SELECT name, city FROM customers;
What happens behind the scenes
- Database scans the customers table
- Picks name and city columns
- Returns matching rows
Where you will use this daily
- Pull user lists
- Check sales numbers
- Validate data issues
Double Tap ♥️ For More
❤9
Glad to see the amazing response on SQL roadmap. ❤️
Today, let's move to the next topic of SQL roadmap:
✅ Database Basics: Primary Key and Foreign Key
Why Keys Exist
Databases store millions of rows. Keys help identify and connect data correctly. Without keys, data breaks fast.
Primary Key
- A primary key uniquely identifies each row in a table
- No two rows share the same primary key
- It never stays empty
Example Table: customers
- Columns: customer_id, name, email, city
- Primary key: customer_id
Why Primary Key Matters
- Prevents duplicate records
- Helps find a row fast
- Keeps data consistent
Foreign Key
- A foreign key links one table to another
- It creates relationships between tables
Example Table: orders
- Columns: order_id, customer_id, order_date, amount
- Foreign key: customer_id
Relationship Explained
- customers.customer_id is primary key
- orders.customer_id is foreign key
- One customer has many orders
Why Foreign Keys Matter
- Enable joins
- Prevent orphan records
- Maintain data integrity
Simple Join Idea
SQL matches customer_id in both tables. This gives customer name with order amount.
Where Beginners Go Wrong
- Using names instead of IDs
- Allowing duplicate primary keys
- Ignoring missing foreign key values
Checkpoint
- You understand primary keys
- You understand foreign keys
- You know how tables connect
Double Tap ♥️ For More
Today, let's move to the next topic of SQL roadmap:
✅ Database Basics: Primary Key and Foreign Key
Why Keys Exist
Databases store millions of rows. Keys help identify and connect data correctly. Without keys, data breaks fast.
Primary Key
- A primary key uniquely identifies each row in a table
- No two rows share the same primary key
- It never stays empty
Example Table: customers
- Columns: customer_id, name, email, city
- Primary key: customer_id
Why Primary Key Matters
- Prevents duplicate records
- Helps find a row fast
- Keeps data consistent
Foreign Key
- A foreign key links one table to another
- It creates relationships between tables
Example Table: orders
- Columns: order_id, customer_id, order_date, amount
- Foreign key: customer_id
Relationship Explained
- customers.customer_id is primary key
- orders.customer_id is foreign key
- One customer has many orders
Why Foreign Keys Matter
- Enable joins
- Prevent orphan records
- Maintain data integrity
Simple Join Idea
SQL matches customer_id in both tables. This gives customer name with order amount.
Where Beginners Go Wrong
- Using names instead of IDs
- Allowing duplicate primary keys
- Ignoring missing foreign key values
Checkpoint
- You understand primary keys
- You understand foreign keys
- You know how tables connect
Double Tap ♥️ For More
❤4
Today, let's move to the next topic of SQL Roadmap:
Basic SQL Queries: SELECT, WHERE, Filtering 🖥️
What SELECT Does
- SELECT chooses columns
- You decide what data you want to see
- Database returns only those columns
Example Table: customers
customer_id | name | city | signup_date
101 | Rahul | Pune | 2024-01-15
102 | Neha | Mumbai | 2024-02-10
103 | Amit | Delhi | 2024-03-05
104 | Priya | Pune | 2024-04-20
Basic SELECT
name | city
Rahul | Pune
Neha | Mumbai
Amit | Delhi
Priya | Pune
What Happens
- Database scans all rows
- Returns name and city columns
- No filtering yet
Why SELECT Matters
- Smaller output
- Faster queries
- Clear analysis
What WHERE Does
- WHERE filters rows
- It answers conditions like who, when, how much
Think Like This
- SELECT decides columns
- WHERE decides rows
Basic WHERE Example
name | city
Rahul | Pune
Priya | Pune
Common Operators
- = equal
- != not equal
- > greater than
- < less than
- > =, <=
Example
name | signup_date
Amit | 2024-03-05
Priya | 2024-04-20
Logical Filters
AND
- All conditions must match
Example:
Output
name
Rahul
Priya
OR
- Any condition can match
Example:
Output
name
Rahul
Neha
Priya
IN
- Shortcut for multiple OR conditions
Example:
Output
name
Rahul
Neha
Amit
Priya
BETWEEN
- Filters within a range
- Inclusive of start and end
Example:
Output
name
Rahul
Neha
Amit
Filtering Numbers
Example table: orders
order_id | customer_id | amount | order_date
1 | 101 | 3000 | 2024-01-16
2 | 102 | 6000 | 2024-02-11
3 | 103 | 4000 | 2024-03-06
order_id | amount
2 | 6000
Filtering Text
- Text values go inside quotes
- Case sensitivity depends on database
Filtering NULL Values
- NULL means missing value
- = NULL does not work
Correct way:
Assume city is NULL for customer_id 103
Output
name
Amit
Exclude NULL:
Output
name
Rahul
Neha
Priya
How SELECT and WHERE Work Together
- FROM picks the table
- WHERE filters rows
- SELECT picks columns
- Result is sent back
Real Business Example
- Manager asks for Pune customers with orders above 5,000
- WHERE applies city and amount filters
- SELECT shows required columns
Assume orders table has customer_id 101 with amount 6000
name
Rahul
Common Beginner Mistakes
- Using WHERE before FROM
- Forgetting quotes for text
- Using = NULL
- Writing SELECT * always
Double Tap ♥️ For More
Basic SQL Queries: SELECT, WHERE, Filtering 🖥️
What SELECT Does
- SELECT chooses columns
- You decide what data you want to see
- Database returns only those columns
Example Table: customers
customer_id | name | city | signup_date
101 | Rahul | Pune | 2024-01-15
102 | Neha | Mumbai | 2024-02-10
103 | Amit | Delhi | 2024-03-05
104 | Priya | Pune | 2024-04-20
Basic SELECT
SELECT name, city FROM customers;Output
name | city
Rahul | Pune
Neha | Mumbai
Amit | Delhi
Priya | Pune
What Happens
- Database scans all rows
- Returns name and city columns
- No filtering yet
Why SELECT Matters
- Smaller output
- Faster queries
- Clear analysis
What WHERE Does
- WHERE filters rows
- It answers conditions like who, when, how much
Think Like This
- SELECT decides columns
- WHERE decides rows
Basic WHERE Example
SELECT name, city FROM customers WHERE city = 'Pune';Output
name | city
Rahul | Pune
Priya | Pune
Common Operators
- = equal
- != not equal
- > greater than
- < less than
- > =, <=
Example
SELECT name, signup_date FROM customers WHERE signup_date >= '2024-03-01';Output
name | signup_date
Amit | 2024-03-05
Priya | 2024-04-20
Logical Filters
AND
- All conditions must match
Example:
SELECT name FROM customers WHERE city = 'Pune' AND signup_date >= '2024-01-01';Output
name
Rahul
Priya
OR
- Any condition can match
Example:
SELECT name FROM customers WHERE city = 'Pune' OR city = 'Mumbai';Output
name
Rahul
Neha
Priya
IN
- Shortcut for multiple OR conditions
Example:
SELECT name FROM customers WHERE city IN ('Pune','Mumbai','Delhi');Output
name
Rahul
Neha
Amit
Priya
BETWEEN
- Filters within a range
- Inclusive of start and end
Example:
SELECT name FROM customers WHERE signup_date BETWEEN '2024-01-01' AND '2024-03-31';Output
name
Rahul
Neha
Amit
Filtering Numbers
Example table: orders
order_id | customer_id | amount | order_date
1 | 101 | 3000 | 2024-01-16
2 | 102 | 6000 | 2024-02-11
3 | 103 | 4000 | 2024-03-06
SELECT order_id, amount FROM orders WHERE amount > 5000;Output
order_id | amount
2 | 6000
Filtering Text
- Text values go inside quotes
- Case sensitivity depends on database
Filtering NULL Values
- NULL means missing value
- = NULL does not work
Correct way:
SELECT name FROM customers WHERE city IS NULL;Assume city is NULL for customer_id 103
Output
name
Amit
Exclude NULL:
SELECT name FROM customers WHERE city IS NOT NULL;Output
name
Rahul
Neha
Priya
How SELECT and WHERE Work Together
- FROM picks the table
- WHERE filters rows
- SELECT picks columns
- Result is sent back
Real Business Example
- Manager asks for Pune customers with orders above 5,000
- WHERE applies city and amount filters
- SELECT shows required columns
Assume orders table has customer_id 101 with amount 6000
SELECT name FROM customers WHERE city = 'Pune' AND customer_id IN (SELECT customer_id FROM orders WHERE amount > 5000);Output
name
Rahul
Common Beginner Mistakes
- Using WHERE before FROM
- Forgetting quotes for text
- Using = NULL
- Writing SELECT * always
Double Tap ♥️ For More
❤9
Today, let's move to the next topic of SQL Roadmap:
✅ Basic SQL Queries: ORDER BY and LIMIT - Sorting and Controlling Output
Why Sorting
- Raw data has no order
- Sorted data reveals patterns
- Analysts sort data in almost every query
What ORDER BY Does
- ORDER BY sorts result rows
- Sorting happens after filtering
- Default order is ascending
Basic Syntax
Example Table: customers
| customer_id | name | city | signup_date |
Sort by Name
- Rows sorted alphabetically by name (A to Z)
Descending Order
- Use DESC for reverse order
Use Cases
- Latest users first
- Highest sales first
- Recent transactions on top
Sorting Numbers
Sorting by Multiple Columns
- First column sorts primary
- Second column breaks ties
LIMIT Explained
- LIMIT restricts number of rows returned
- Used to preview data
- Used to get top results
Top N Queries
Filtering + Sorting + Limiting Together
Execution order:
1. FROM
2. WHERE
3. ORDER BY
4. LIMIT
Double Tap ♥️ For More
✅ Basic SQL Queries: ORDER BY and LIMIT - Sorting and Controlling Output
Why Sorting
- Raw data has no order
- Sorted data reveals patterns
- Analysts sort data in almost every query
What ORDER BY Does
- ORDER BY sorts result rows
- Sorting happens after filtering
- Default order is ascending
Basic Syntax
SELECT column_name
FROM table_name
ORDER BY column_name;
Example Table: customers
| customer_id | name | city | signup_date |
Sort by Name
SELECT name, city
FROM customers
ORDER BY name;
- Rows sorted alphabetically by name (A to Z)
Descending Order
- Use DESC for reverse order
SELECT name, signup_date
FROM customers
ORDER BY signup_date DESC;
Use Cases
- Latest users first
- Highest sales first
- Recent transactions on top
Sorting Numbers
SELECT order_id, amount
FROM orders
ORDER BY amount DESC;
Sorting by Multiple Columns
- First column sorts primary
- Second column breaks ties
SELECT city, signup_date
FROM customers
ORDER BY city, signup_date DESC;
LIMIT Explained
- LIMIT restricts number of rows returned
- Used to preview data
- Used to get top results
SELECT name, signup_date
FROM customers
ORDER BY signup_date DESC
LIMIT 5;
Top N Queries
SELECT name, amount
FROM orders
ORDER BY amount DESC
LIMIT 10;
Filtering + Sorting + Limiting Together
Execution order:
1. FROM
2. WHERE
3. ORDER BY
4. LIMIT
SELECT name, amount
FROM orders
WHERE amount > 5000
ORDER BY amount DESC
LIMIT 3;
Double Tap ♥️ For More
❤7
Today, let's move to the next topic of SQL Roadmap:
✅ Basic SQL Queries: Aggregations and GROUP BY
• Why aggregations matter
• Raw rows hide patterns
• Businesses care about totals, averages, counts
• Aggregations turn rows into answers
• Common aggregate functions
• COUNT: counts rows
• SUM: adds values
• AVG: finds average
• MIN: finds smallest value
• MAX: finds largest value
• Examples
SELECT COUNT(*) FROM orders; -- total orders
SELECT SUM(amount) FROM orders; -- total revenue
SELECT AVG(amount) FROM orders; -- average order value
SELECT MIN(amount), MAX(amount) FROM orders; -- spend range
• GROUP BY
• Groups rows by a column
• Applies aggregation per group
• One result per group
SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id; -- total spend per customer
SELECT order_date, COUNT(*) FROM orders GROUP BY order_date; -- daily order volume
• Important rule
Every column in SELECT must be aggregated or present in GROUP BY.
• Using WHERE with GROUP BY
SELECT customer_id, SUM(amount) FROM orders
WHERE amount > 5000
GROUP BY customer_id; -- high-value orders per customer
Real business use:
• Revenue per customer
• Orders per day
• Average order value per city
SQL Roadmap: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v/1615
Double Tap ♥️ For More
✅ Basic SQL Queries: Aggregations and GROUP BY
• Why aggregations matter
• Raw rows hide patterns
• Businesses care about totals, averages, counts
• Aggregations turn rows into answers
• Common aggregate functions
• COUNT: counts rows
• SUM: adds values
• AVG: finds average
• MIN: finds smallest value
• MAX: finds largest value
• Examples
SELECT COUNT(*) FROM orders; -- total orders
SELECT SUM(amount) FROM orders; -- total revenue
SELECT AVG(amount) FROM orders; -- average order value
SELECT MIN(amount), MAX(amount) FROM orders; -- spend range
• GROUP BY
• Groups rows by a column
• Applies aggregation per group
• One result per group
SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id; -- total spend per customer
SELECT order_date, COUNT(*) FROM orders GROUP BY order_date; -- daily order volume
• Important rule
Every column in SELECT must be aggregated or present in GROUP BY.
• Using WHERE with GROUP BY
SELECT customer_id, SUM(amount) FROM orders
WHERE amount > 5000
GROUP BY customer_id; -- high-value orders per customer
Real business use:
• Revenue per customer
• Orders per day
• Average order value per city
SQL Roadmap: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v/1615
Double Tap ♥️ For More
❤6
Today, let's move to the next topic of SQL Roadmap:
✅ HAVING vs WHERE
Why HAVING exists
- WHERE filters individual rows.
- Aggregations work on groups.
- You need HAVING to filter groups.
Key difference
- WHERE filters rows before grouping
- HAVING filters groups after aggregation
Think in order
- FROM reads table
- WHERE filters rows
- GROUP BY creates groups
- HAVING filters groups
Example table. orders
order_id | customer_id | amount | order_date
WHERE with aggregation
What this query does
- Removes orders below 5,000
- Groups remaining orders by customer
- Calculates total high value spend per customer
HAVING example
What this query does
- Groups all orders by customer
- Calculates total spend per customer
- Keeps only customers with total spend above 20,000
WHERE vs HAVING side by side
Use WHERE when
- Filtering raw rows
- Condition does not involve aggregate functions
Use HAVING when
- Filtering aggregated results
- Condition uses SUM, COUNT, AVG
Combined WHERE and HAVING
What this query does
- Keeps orders from 2024 onward
- Groups orders by customer
- Counts orders per customer
- Returns customers with at least 5 orders
Common beginner mistakes
- Using HAVING without GROUP BY
- Using WHERE with SUM or COUNT
- Mixing WHERE and HAVING logic
Interview one-liner
WHERE filters rows. HAVING filters groups.
Double Tap ❤️ For More
✅ HAVING vs WHERE
Why HAVING exists
- WHERE filters individual rows.
- Aggregations work on groups.
- You need HAVING to filter groups.
Key difference
- WHERE filters rows before grouping
- HAVING filters groups after aggregation
Think in order
- FROM reads table
- WHERE filters rows
- GROUP BY creates groups
- HAVING filters groups
Example table. orders
order_id | customer_id | amount | order_date
WHERE with aggregation
SELECT customer_id, SUM(amount)
FROM orders
WHERE amount > 5000
GROUP BY customer_id;
What this query does
- Removes orders below 5,000
- Groups remaining orders by customer
- Calculates total high value spend per customer
HAVING example
SELECT customer_id, SUM(amount)
FROM orders
GROUP BY customer_id
HAVING SUM(amount) > 20000;
What this query does
- Groups all orders by customer
- Calculates total spend per customer
- Keeps only customers with total spend above 20,000
WHERE vs HAVING side by side
Use WHERE when
- Filtering raw rows
- Condition does not involve aggregate functions
Use HAVING when
- Filtering aggregated results
- Condition uses SUM, COUNT, AVG
Combined WHERE and HAVING
SELECT customer_id, COUNT(*)
FROM orders
WHERE order_date >= '2024-01-01'
GROUP BY customer_id
HAVING COUNT(*) >= 5;
What this query does
- Keeps orders from 2024 onward
- Groups orders by customer
- Counts orders per customer
- Returns customers with at least 5 orders
Common beginner mistakes
- Using HAVING without GROUP BY
- Using WHERE with SUM or COUNT
- Mixing WHERE and HAVING logic
Interview one-liner
WHERE filters rows. HAVING filters groups.
Double Tap ❤️ For More
❤4
Please go through this top 5 SQL projects with Datasets that you can practice and can add in your resume
🚀1. Web Analytics:
(https://www.kaggle.com/zynicide/wine-reviews)
🚀2. Healthcare Data Analysis:
(https://www.kaggle.com/cdc/mortality)
📌3. E-commerce Analysis:
(https://www.kaggle.com/olistbr/brazilian-ecommerce)
🚀4. Inventory Management:
(https://www.kaggle.com/code/govindji/inventory-management)
🚀 5. Analysis of Sales Data:
(https://www.kaggle.com/kyanyoga/sample-sales-data)
Small suggestion from my side for non tech students: kindly pick those datasets which you like the subject in general, that way you will be more excited to practice it, instead of just doing it for the sake of resume, you will learn SQL more passionately, since it’s a programming language try to make it more exciting for yourself.
Hope this piece of information helps you
Join for more -> https://t.iss.one/addlist/4q2PYC0pH_VjZDk5
ENJOY LEARNING 👍👍
🚀1. Web Analytics:
(https://www.kaggle.com/zynicide/wine-reviews)
🚀2. Healthcare Data Analysis:
(https://www.kaggle.com/cdc/mortality)
📌3. E-commerce Analysis:
(https://www.kaggle.com/olistbr/brazilian-ecommerce)
🚀4. Inventory Management:
(https://www.kaggle.com/code/govindji/inventory-management)
🚀 5. Analysis of Sales Data:
(https://www.kaggle.com/kyanyoga/sample-sales-data)
Small suggestion from my side for non tech students: kindly pick those datasets which you like the subject in general, that way you will be more excited to practice it, instead of just doing it for the sake of resume, you will learn SQL more passionately, since it’s a programming language try to make it more exciting for yourself.
Hope this piece of information helps you
Join for more -> https://t.iss.one/addlist/4q2PYC0pH_VjZDk5
ENJOY LEARNING 👍👍
👍2❤1
Today, let's move to the next topic of SQL Roadmap:
✅ SQL JOINS
What a JOIN is
• A JOIN combines data from two or more tables
• Tables connect using a common column
• That column is usually an ID
• JOIN answers questions one table cannot answer
Why JOINs exist
• Customer details sit in one table
• Orders sit in another table
• JOIN links customers to their orders
Example tables
customers
customer_id | name | city
orders
order_id | customer_id | amount
Connection
• customers.customer_id is primary key
• orders.customer_id is foreign key
• This shared column enables JOIN
Types of JOINs you must know
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• FULL JOIN
• SELF JOIN
INNER JOIN
• Returns only matching rows from both tables
• Drops anything without a match
• Matches customers with their orders
• Shows only customers who placed orders
• Removes customers with no orders
• Removes orders without customers
LEFT JOIN
• Returns all rows from left table
• Matches data from right table
• Shows NULL when no match exists
• Returns every customer
• Shows order amount if available
• Shows NULL if customer never ordered
RIGHT JOIN
• Returns all rows from right table
• Matches data from left table
• Opposite of LEFT JOIN
• Returns all orders
• Shows customer name if exists
• Shows NULL for missing customer data
FULL JOIN
• Returns all rows from both tables
• Matches where possible
• Shows NULL when no match
• Shows all customers
• Shows all orders
• Includes unmatched data from both sides
SELF JOIN
• Table joins with itself
• Used for hierarchy or comparison
• Matches employee with manager
• Uses same table twice
• Shows reporting hierarchy
JOIN Comparison Summary
• INNER JOIN: Only matching data
• LEFT JOIN: All left table rows
• RIGHT JOIN: All right table rows
• FULL JOIN: Everything from both tables
• SELF JOIN: Table joins itself
Double Tap ♥️ For More
✅ SQL JOINS
What a JOIN is
• A JOIN combines data from two or more tables
• Tables connect using a common column
• That column is usually an ID
• JOIN answers questions one table cannot answer
Why JOINs exist
• Customer details sit in one table
• Orders sit in another table
• JOIN links customers to their orders
Example tables
customers
customer_id | name | city
orders
order_id | customer_id | amount
Connection
• customers.customer_id is primary key
• orders.customer_id is foreign key
• This shared column enables JOIN
Types of JOINs you must know
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• FULL JOIN
• SELF JOIN
INNER JOIN
• Returns only matching rows from both tables
• Drops anything without a match
SELECT name, amount
FROM customers
INNER JOIN orders
ON customers.customer_id = orders.customer_id;
• Matches customers with their orders
• Shows only customers who placed orders
• Removes customers with no orders
• Removes orders without customers
LEFT JOIN
• Returns all rows from left table
• Matches data from right table
• Shows NULL when no match exists
SELECT name, amount
FROM customers
LEFT JOIN orders
ON customers.customer_id = orders.customer_id;
• Returns every customer
• Shows order amount if available
• Shows NULL if customer never ordered
RIGHT JOIN
• Returns all rows from right table
• Matches data from left table
• Opposite of LEFT JOIN
SELECT name, amount
FROM customers
RIGHT JOIN orders
ON customers.customer_id = orders.customer_id;
• Returns all orders
• Shows customer name if exists
• Shows NULL for missing customer data
FULL JOIN
• Returns all rows from both tables
• Matches where possible
• Shows NULL when no match
SELECT name, amount
FROM customers
FULL JOIN orders
ON customers.customer_id = orders.customer_id;
• Shows all customers
• Shows all orders
• Includes unmatched data from both sides
SELF JOIN
• Table joins with itself
• Used for hierarchy or comparison
SELECT e.name, m.name AS manager_name
FROM employees e
LEFT JOIN employees m
ON e.manager_id = m.employee_id;
• Matches employee with manager
• Uses same table twice
• Shows reporting hierarchy
JOIN Comparison Summary
• INNER JOIN: Only matching data
• LEFT JOIN: All left table rows
• RIGHT JOIN: All right table rows
• FULL JOIN: Everything from both tables
• SELF JOIN: Table joins itself
Double Tap ♥️ For More
❤8
If you want to Excel at using the most used database language in the world, learn these powerful SQL features:
• Wildcards (%, _) – Flexible pattern matching
• Window Functions – ROW_NUMBER(), RANK(), DENSE_RANK(), LEAD(), LAG()
• Common Table Expressions (CTEs) – WITH for better readability
• Recursive Queries – Handle hierarchical data
• STRING Functions – LEFT(), RIGHT(), LEN(), TRIM(), UPPER(), LOWER()
• Date Functions – DATEDIFF(), DATEADD(), FORMAT()
• Pivot & Unpivot – Transform row data into columns
• Aggregate Functions – SUM(), AVG(), COUNT(), MIN(), MAX()
• Joins & Self Joins – Master INNER, LEFT, RIGHT, FULL, SELF JOIN
• Indexing – Speed up queries with CREATE INDEX
Like it if you need a complete tutorial on all these topics! 👍❤️
#sql
• Wildcards (%, _) – Flexible pattern matching
• Window Functions – ROW_NUMBER(), RANK(), DENSE_RANK(), LEAD(), LAG()
• Common Table Expressions (CTEs) – WITH for better readability
• Recursive Queries – Handle hierarchical data
• STRING Functions – LEFT(), RIGHT(), LEN(), TRIM(), UPPER(), LOWER()
• Date Functions – DATEDIFF(), DATEADD(), FORMAT()
• Pivot & Unpivot – Transform row data into columns
• Aggregate Functions – SUM(), AVG(), COUNT(), MIN(), MAX()
• Joins & Self Joins – Master INNER, LEFT, RIGHT, FULL, SELF JOIN
• Indexing – Speed up queries with CREATE INDEX
Like it if you need a complete tutorial on all these topics! 👍❤️
#sql
👍6❤4
Useful WhatsApp Channels to Boost Your Career in 2026
ChatGPT: https://whatsapp.com/channel/0029VapThS265yDAfwe97c23
Artificial Intelligence: https://whatsapp.com/channel/0029Va4QUHa6rsQjhITHK82y
Web Development: https://whatsapp.com/channel/0029VaiSdWu4NVis9yNEE72z
Stock Marketing: https://whatsapp.com/channel/0029VatOdpD2f3EPbBlLYW0h
Finance: https://whatsapp.com/channel/0029Vax0HTt7Noa40kNI2B1P
Marketing: https://whatsapp.com/channel/0029VbB4goz6rsR1YtmiFV3f
Crypto: https://whatsapp.com/channel/0029Vb3H903DOQIUyaFTuw3P
Generative AI: https://whatsapp.com/channel/0029VazaRBY2UPBNj1aCrN0U
Sales: https://whatsapp.com/channel/0029VbC3NVX4dTnEv8IYCs3U
Digital Marketing: https://whatsapp.com/channel/0029VbAuBjwLSmbjUbItjM1t
Data Engineering: https://whatsapp.com/channel/0029Vaovs0ZKbYMKXvKRYi3C
Data Science: https://whatsapp.com/channel/0029Va8v3eo1NCrQfGMseL2D
UI/UX Design: https://whatsapp.com/channel/0029Vb5dho06LwHmgMLYci1P
Project Management: https://whatsapp.com/channel/0029Vb6QIAUJUM2SwC03jn2W
Entrepreneurs: https://whatsapp.com/channel/0029Vb2N3YA2phHJfsMrHZ0b
Content Creation: https://whatsapp.com/channel/0029VbC7n5FLo4hdy90kVx34
Freelancers: https://whatsapp.com/channel/0029Vb1U4wG9sBI22PXhSy0r
AI Tools: https://whatsapp.com/channel/0029VaojSv9LCoX0gBZUxX3B
Data Analysts: https://whatsapp.com/channel/0029VaGgzAk72WTmQFERKh02
Jobs: https://whatsapp.com/channel/0029VaI5CV93AzNUiZ5Tt226
Science Facts: https://whatsapp.com/channel/0029Vb5m9UR6xCSQo1YXTA0O
Psychology: https://whatsapp.com/channel/0029Vb62WgKG8l5KlJpcIe2r
Prompt Engineering: https://whatsapp.com/channel/0029Vb6ISO1Fsn0kEemhE03b
Coding: https://whatsapp.com/channel/0029VamhFMt7j6fx4bYsX908
Double Tap ♥️ For More
ChatGPT: https://whatsapp.com/channel/0029VapThS265yDAfwe97c23
Artificial Intelligence: https://whatsapp.com/channel/0029Va4QUHa6rsQjhITHK82y
Web Development: https://whatsapp.com/channel/0029VaiSdWu4NVis9yNEE72z
Stock Marketing: https://whatsapp.com/channel/0029VatOdpD2f3EPbBlLYW0h
Finance: https://whatsapp.com/channel/0029Vax0HTt7Noa40kNI2B1P
Marketing: https://whatsapp.com/channel/0029VbB4goz6rsR1YtmiFV3f
Crypto: https://whatsapp.com/channel/0029Vb3H903DOQIUyaFTuw3P
Generative AI: https://whatsapp.com/channel/0029VazaRBY2UPBNj1aCrN0U
Sales: https://whatsapp.com/channel/0029VbC3NVX4dTnEv8IYCs3U
Digital Marketing: https://whatsapp.com/channel/0029VbAuBjwLSmbjUbItjM1t
Data Engineering: https://whatsapp.com/channel/0029Vaovs0ZKbYMKXvKRYi3C
Data Science: https://whatsapp.com/channel/0029Va8v3eo1NCrQfGMseL2D
UI/UX Design: https://whatsapp.com/channel/0029Vb5dho06LwHmgMLYci1P
Project Management: https://whatsapp.com/channel/0029Vb6QIAUJUM2SwC03jn2W
Entrepreneurs: https://whatsapp.com/channel/0029Vb2N3YA2phHJfsMrHZ0b
Content Creation: https://whatsapp.com/channel/0029VbC7n5FLo4hdy90kVx34
Freelancers: https://whatsapp.com/channel/0029Vb1U4wG9sBI22PXhSy0r
AI Tools: https://whatsapp.com/channel/0029VaojSv9LCoX0gBZUxX3B
Data Analysts: https://whatsapp.com/channel/0029VaGgzAk72WTmQFERKh02
Jobs: https://whatsapp.com/channel/0029VaI5CV93AzNUiZ5Tt226
Science Facts: https://whatsapp.com/channel/0029Vb5m9UR6xCSQo1YXTA0O
Psychology: https://whatsapp.com/channel/0029Vb62WgKG8l5KlJpcIe2r
Prompt Engineering: https://whatsapp.com/channel/0029Vb6ISO1Fsn0kEemhE03b
Coding: https://whatsapp.com/channel/0029VamhFMt7j6fx4bYsX908
Double Tap ♥️ For More
❤7👏2
✅ SQL JOINS — Scenario-Based Interview Questions with Answers
Scenario 1: Find customers who have never placed an order
Tables: customers(customer_id, name) orders(order_id, customer_id);
Question: Business wants a list of customers with zero orders.
Answer:
SELECT c.customer_id, c.name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.customer_id IS NULL;
Why this works
• LEFT JOIN keeps all customers
• Orders missing → NULL
• WHERE filters only non-ordering customers
Scenario 2: Get total revenue per customer, including customers with no orders
Question: Show every customer and their total spend. If no orders, show 0.
Answer:
SELECT c.customer_id, c.name, COALESCE(SUM(o.amount), 0) AS total_spend FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name;
Explanation
• LEFT JOIN keeps all customers
• SUM aggregates orders
• COALESCE converts NULL to 0
Scenario 3: Find orders that don’t have a matching customer
Question: Audit data to find orphan orders.
Answer:
SELECT o.order_id, o.customer_id FROM orders o LEFT JOIN customers c ON o.customer_id = c.customer_id WHERE c.customer_id IS NULL;
Explanation
• LEFT JOIN from orders
• Missing customers become NULL
• Filters invalid data
Scenario 4: Get only customers who have placed at least one order
Question: Marketing wants only active customers.
Answer:
SELECT DISTINCT c.customer_id, c.name FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id;
Explanation
• INNER JOIN keeps only matching rows
• Customers without orders are excluded
Scenario 5: Find customers with more than 3 orders
Answer:
SELECT c.customer_id, c.name, COUNT(o.order_id) AS order_count FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name HAVING COUNT(o.order_id) > 3;
Explanation
• JOIN combines data
• GROUP BY customer
• HAVING filters aggregated count
Scenario 6: Show latest order for each customer
Answer:
SELECT c.customer_id, c.name, MAX(o.order_date) AS last_order_date FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name;
Explanation
• JOIN connects customers and orders
• MAX finds latest order per customer
Scenario 7: Find customers who ordered in 2024 but not in 2025
Answer:
SELECT DISTINCT c.customer_id, c.name FROM customers c INNER JOIN orders o2024 ON c.customer_id = o2024.customer_id LEFT JOIN orders o2025 ON c.customer_id = o2025.customer_id AND o2025.order_date >= '2025-01-01' WHERE o2024.order_date BETWEEN '2024-01-01' AND '2024-12-31' AND o2025.customer_id IS NULL;
Explanation
• INNER JOIN ensures 2024 orders
• LEFT JOIN checks absence in 2025
• NULL filter removes 2025 buyers
Scenario 8: Employee-Manager hierarchy (SELF JOIN)
Table: employees(employee_id, name, manager_id);
Answer:
SELECT e.name AS employee, m.name AS manager FROM employees e LEFT JOIN employees m ON e.manager_id = m.employee_id;
Explanation
• Same table joined twice
• Shows reporting structure
Scenario 9: Revenue by city
Answer:
SELECT c.city, SUM(o.amount) AS revenue FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.city;
Explanation
• JOIN links customers to orders
• GROUP BY city
• SUM calculates revenue
Scenario 10: Duplicate explosion after JOIN (classic trap)
Question: Why does this query show inflated revenue?
SELECT SUM(o.amount) FROM customers c JOIN orders o ON c.customer_id = o.customer_id;
Answer:
• Customer table may have duplicates
• JOIN multiplies rows
• Revenue gets inflated
Fix:
SELECT SUM(amount) FROM orders; or deduplicate customers before joining.
Interview golden rule for JOINS
Always explain:
1️⃣ Which table is LEFT
2️⃣ Which table is RIGHT
3️⃣ What rows are kept
4️⃣ Where NULLs appear
Double Tap ♥️ For More
Scenario 1: Find customers who have never placed an order
Tables: customers(customer_id, name) orders(order_id, customer_id);
Question: Business wants a list of customers with zero orders.
Answer:
SELECT c.customer_id, c.name FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id WHERE o.customer_id IS NULL;
Why this works
• LEFT JOIN keeps all customers
• Orders missing → NULL
• WHERE filters only non-ordering customers
Scenario 2: Get total revenue per customer, including customers with no orders
Question: Show every customer and their total spend. If no orders, show 0.
Answer:
SELECT c.customer_id, c.name, COALESCE(SUM(o.amount), 0) AS total_spend FROM customers c LEFT JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name;
Explanation
• LEFT JOIN keeps all customers
• SUM aggregates orders
• COALESCE converts NULL to 0
Scenario 3: Find orders that don’t have a matching customer
Question: Audit data to find orphan orders.
Answer:
SELECT o.order_id, o.customer_id FROM orders o LEFT JOIN customers c ON o.customer_id = c.customer_id WHERE c.customer_id IS NULL;
Explanation
• LEFT JOIN from orders
• Missing customers become NULL
• Filters invalid data
Scenario 4: Get only customers who have placed at least one order
Question: Marketing wants only active customers.
Answer:
SELECT DISTINCT c.customer_id, c.name FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id;
Explanation
• INNER JOIN keeps only matching rows
• Customers without orders are excluded
Scenario 5: Find customers with more than 3 orders
Answer:
SELECT c.customer_id, c.name, COUNT(o.order_id) AS order_count FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name HAVING COUNT(o.order_id) > 3;
Explanation
• JOIN combines data
• GROUP BY customer
• HAVING filters aggregated count
Scenario 6: Show latest order for each customer
Answer:
SELECT c.customer_id, c.name, MAX(o.order_date) AS last_order_date FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name;
Explanation
• JOIN connects customers and orders
• MAX finds latest order per customer
Scenario 7: Find customers who ordered in 2024 but not in 2025
Answer:
SELECT DISTINCT c.customer_id, c.name FROM customers c INNER JOIN orders o2024 ON c.customer_id = o2024.customer_id LEFT JOIN orders o2025 ON c.customer_id = o2025.customer_id AND o2025.order_date >= '2025-01-01' WHERE o2024.order_date BETWEEN '2024-01-01' AND '2024-12-31' AND o2025.customer_id IS NULL;
Explanation
• INNER JOIN ensures 2024 orders
• LEFT JOIN checks absence in 2025
• NULL filter removes 2025 buyers
Scenario 8: Employee-Manager hierarchy (SELF JOIN)
Table: employees(employee_id, name, manager_id);
Answer:
SELECT e.name AS employee, m.name AS manager FROM employees e LEFT JOIN employees m ON e.manager_id = m.employee_id;
Explanation
• Same table joined twice
• Shows reporting structure
Scenario 9: Revenue by city
Answer:
SELECT c.city, SUM(o.amount) AS revenue FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.city;
Explanation
• JOIN links customers to orders
• GROUP BY city
• SUM calculates revenue
Scenario 10: Duplicate explosion after JOIN (classic trap)
Question: Why does this query show inflated revenue?
SELECT SUM(o.amount) FROM customers c JOIN orders o ON c.customer_id = o.customer_id;
Answer:
• Customer table may have duplicates
• JOIN multiplies rows
• Revenue gets inflated
Fix:
SELECT SUM(amount) FROM orders; or deduplicate customers before joining.
Interview golden rule for JOINS
Always explain:
1️⃣ Which table is LEFT
2️⃣ Which table is RIGHT
3️⃣ What rows are kept
4️⃣ Where NULLs appear
Double Tap ♥️ For More
❤7👍1👏1
SQL Detailed Roadmap
|
| | |-- Fundamentals
| |-- Introduction to Databases
| | |-- What SQL does
| | |-- Relational model
| | |-- Tables, rows, columns
| |-- Keys and Constraints
| | |-- Primary keys
| | |-- Foreign keys
| | |-- Unique and check constraints
| |-- Normalization
| | |-- 1NF, 2NF, 3NF
| | |-- ER diagrams
| | |-- Core SQL
| |-- SQL Basics
| | |-- SELECT, WHERE, ORDER BY
| | |-- GROUP BY and HAVING
| | |-- JOINS: INNER, LEFT, RIGHT, FULL
| |-- Intermediate SQL
| | |-- Subqueries
| | |-- CTEs
| | |-- CASE statements
| | |-- Aggregations
| |-- Advanced SQL
| | |-- Window functions
| | |-- Analytical functions
| | |-- Ranking, moving averages, lag and lead
| | |-- UNION, INTERSECT, EXCEPT
| | |-- Data Management
| |-- Data Types
| | |-- Numeric, text, date, JSON
| |-- Indexes
| | |-- B tree and hash indexes
| | |-- When to create indexes
| |-- Transactions
| | |-- ACID properties
| |-- Views
| | |-- Standard views
| | |-- Materialized views
| | |-- Database Design
| |-- Schema Design
| | |-- Star schema
| | |-- Snowflake schema
| |-- Fact and Dimension Tables
| |-- Constraints for clean data
| | |-- Performance Tuning
| |-- Query Optimization
| | |-- Execution plans
| | |-- Index usage
| | |-- Reducing scans
| |-- Partitioning
| | |-- Horizontal partitioning
| | |-- Sharding basics
| | |-- SQL for Analytics
| |-- KPI calculations
| |-- Cohort analysis
| |-- Funnel analysis
| |-- Churn and retention tables
| |-- Time based aggregations
| |-- Window functions for metrics
| | |-- SQL for Data Engineering
| |-- ETL Workflows
| | |-- Staging tables
| | |-- Transformations
| | |-- Incremental loads
| |-- Data Warehousing
| | |-- Snowflake
| | |-- Redshift
| | |-- BigQuery
| |-- dbt Basics
| | |-- Models
| | |-- Tests
| | |-- Lineage
| | |-- Tools and Platforms
| |-- PostgreSQL
| |-- MySQL
| |-- SQL Server
| |-- Oracle
| |-- SQLite
| |-- Cloud SQL
| |-- BigQuery UI
| |-- Snowflake Worksheets
| | |-- Projects
| |-- Build a sales reporting system
| |-- Create a star schema from raw CSV files
| |-- Design a customer segmentation query
| |-- Build a churn dashboard dataset
| |-- Optimize slow queries in a sample DB
| |-- Create an analytics pipeline with dbt
| | |-- Soft Skills and Career Prep
| |-- SQL interview patterns
| |-- Joins practice
| |-- Window function drills
| |-- Query writing speed
| |-- Git and GitHub
| |-- Data storytelling
| | |-- Bonus Topics
| |-- NoSQL intro
| |-- Working with JSON fields
| |-- Spatial SQL
| |-- Time series tables
| |-- CDC concepts
| |-- Real time analytics
| | |-- Community and Growth
| |-- LeetCode SQL
| |-- Kaggle datasets with SQL
| |-- GitHub projects
| |-- LinkedIn posts
| |-- Open source contributions
Free Resources to learn SQL
• W3Schools SQL
https://www.w3schools.com/sql/
• SQL Programming
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
• SQL Notes
https://whatsapp.com/channel/0029Vb6hJmM9hXFCWNtQX944
• Mode Analytics SQL tutorials
https://mode.com/sql-tutorial/
• Data Analytics Resources
https://t.iss.one/sqlspecialist
• HackerRank SQL practice
https://www.hackerrank.com/domains/sql
• LeetCode SQL problems
https://leetcode.com/problemset/database/
• Data Engineering Resources
https://whatsapp.com/channel/0029Vaovs0ZKbYMKXvKRYi3C
• Khan Academy SQL basics
https://www.khanacademy.org/computing/computer-programming/sql
• PostgreSQL official docs
https://www.postgresql.org/docs/
• MySQL official docs
https://dev.mysql.com/doc/
• NoSQL Resources
https://whatsapp.com/channel/0029VaxA2hTHgZWe5FpFjm3p
Double Tap ❤️ For More
|
| | |-- Fundamentals
| |-- Introduction to Databases
| | |-- What SQL does
| | |-- Relational model
| | |-- Tables, rows, columns
| |-- Keys and Constraints
| | |-- Primary keys
| | |-- Foreign keys
| | |-- Unique and check constraints
| |-- Normalization
| | |-- 1NF, 2NF, 3NF
| | |-- ER diagrams
| | |-- Core SQL
| |-- SQL Basics
| | |-- SELECT, WHERE, ORDER BY
| | |-- GROUP BY and HAVING
| | |-- JOINS: INNER, LEFT, RIGHT, FULL
| |-- Intermediate SQL
| | |-- Subqueries
| | |-- CTEs
| | |-- CASE statements
| | |-- Aggregations
| |-- Advanced SQL
| | |-- Window functions
| | |-- Analytical functions
| | |-- Ranking, moving averages, lag and lead
| | |-- UNION, INTERSECT, EXCEPT
| | |-- Data Management
| |-- Data Types
| | |-- Numeric, text, date, JSON
| |-- Indexes
| | |-- B tree and hash indexes
| | |-- When to create indexes
| |-- Transactions
| | |-- ACID properties
| |-- Views
| | |-- Standard views
| | |-- Materialized views
| | |-- Database Design
| |-- Schema Design
| | |-- Star schema
| | |-- Snowflake schema
| |-- Fact and Dimension Tables
| |-- Constraints for clean data
| | |-- Performance Tuning
| |-- Query Optimization
| | |-- Execution plans
| | |-- Index usage
| | |-- Reducing scans
| |-- Partitioning
| | |-- Horizontal partitioning
| | |-- Sharding basics
| | |-- SQL for Analytics
| |-- KPI calculations
| |-- Cohort analysis
| |-- Funnel analysis
| |-- Churn and retention tables
| |-- Time based aggregations
| |-- Window functions for metrics
| | |-- SQL for Data Engineering
| |-- ETL Workflows
| | |-- Staging tables
| | |-- Transformations
| | |-- Incremental loads
| |-- Data Warehousing
| | |-- Snowflake
| | |-- Redshift
| | |-- BigQuery
| |-- dbt Basics
| | |-- Models
| | |-- Tests
| | |-- Lineage
| | |-- Tools and Platforms
| |-- PostgreSQL
| |-- MySQL
| |-- SQL Server
| |-- Oracle
| |-- SQLite
| |-- Cloud SQL
| |-- BigQuery UI
| |-- Snowflake Worksheets
| | |-- Projects
| |-- Build a sales reporting system
| |-- Create a star schema from raw CSV files
| |-- Design a customer segmentation query
| |-- Build a churn dashboard dataset
| |-- Optimize slow queries in a sample DB
| |-- Create an analytics pipeline with dbt
| | |-- Soft Skills and Career Prep
| |-- SQL interview patterns
| |-- Joins practice
| |-- Window function drills
| |-- Query writing speed
| |-- Git and GitHub
| |-- Data storytelling
| | |-- Bonus Topics
| |-- NoSQL intro
| |-- Working with JSON fields
| |-- Spatial SQL
| |-- Time series tables
| |-- CDC concepts
| |-- Real time analytics
| | |-- Community and Growth
| |-- LeetCode SQL
| |-- Kaggle datasets with SQL
| |-- GitHub projects
| |-- LinkedIn posts
| |-- Open source contributions
Free Resources to learn SQL
• W3Schools SQL
https://www.w3schools.com/sql/
• SQL Programming
https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
• SQL Notes
https://whatsapp.com/channel/0029Vb6hJmM9hXFCWNtQX944
• Mode Analytics SQL tutorials
https://mode.com/sql-tutorial/
• Data Analytics Resources
https://t.iss.one/sqlspecialist
• HackerRank SQL practice
https://www.hackerrank.com/domains/sql
• LeetCode SQL problems
https://leetcode.com/problemset/database/
• Data Engineering Resources
https://whatsapp.com/channel/0029Vaovs0ZKbYMKXvKRYi3C
• Khan Academy SQL basics
https://www.khanacademy.org/computing/computer-programming/sql
• PostgreSQL official docs
https://www.postgresql.org/docs/
• MySQL official docs
https://dev.mysql.com/doc/
• NoSQL Resources
https://whatsapp.com/channel/0029VaxA2hTHgZWe5FpFjm3p
Double Tap ❤️ For More
❤8
✅ Handling NULL Values in SQL
What is NULL in SQL?
NULL means missing or unknown data.
It does NOT mean:
- 0
- Empty string ''
- False
👉 NULL = no value at all
Why NULLs exist in real data
Real business data is messy:
- Customer didn’t provide city
- Order amount not updated yet
- Employee not assigned a manager
So databases allow NULLs.
Example Table
Data: customers
customer_id: 1, name: Rahul, city: Pune, email: [email protected]
customer_id: 2, name: Neha, city: NULL, email: [email protected]
customer_id: 3, name: Aman, city: Delhi, email: NULL
🚫 Biggest Beginner Mistake
❌ This is WRONG
👉 This will return no rows
Why? Because NULL cannot be compared using = or !=
✅ Correct Way to Handle NULL
1️⃣ IS NULL: Used to find missing values
What this query does:
- Scans all rows
- Returns customers where city is missing
2️⃣ IS NOT NULL: Used to exclude missing values
What this query does:
- Returns customers who have email
- Removes rows with NULL email
NULLs in JOINs (Very Important)
Customers data:
customer_id: 1, name: Rahul
customer_id: 2, name: Neha
customer_id: 3, name: Aman
Orders data:
order_id: 101, customer_id: 1, amount: 5000
order_id: 102, customer_id: 1, amount: 3000
LEFT JOIN with NULL check
👉 Find customers with NO orders
What this query does:
- Keeps all customers
- Matches orders where possible
- Filters customers without orders
NULLs in Aggregations
COUNT behavior (INTERVIEW FAVORITE)
👉 Counts all rows
👉 Counts only non-NULL cities
Example
✔ Counts customers who have email
❌ Ignores NULL emails
Handling NULL using COALESCE
What this query does:
- If city exists → show city
- If city is NULL → show “Unknown”
NULLs in SUM / AVG
👉 NULL values are ignored, not treated as 0
But if all rows are NULL, result is NULL.
Safe approach:
NULL vs Empty String
- NULL: No value
- '': Empty value
Common NULL Mistakes (Must Avoid)
❌ Using = NULL
❌ Forgetting NULLs in LEFT JOIN
❌ Assuming COUNT(column) counts NULL
❌ Ignoring NULL replacement in reports
Interview One-Liner 💡
> NULL represents missing data and must be handled using IS NULL, IS NOT NULL, or COALESCE, not with =.
Double Tap ♥️ For More
What is NULL in SQL?
NULL means missing or unknown data.
It does NOT mean:
- 0
- Empty string ''
- False
👉 NULL = no value at all
Why NULLs exist in real data
Real business data is messy:
- Customer didn’t provide city
- Order amount not updated yet
- Employee not assigned a manager
So databases allow NULLs.
Example Table
Data: customers
customer_id: 1, name: Rahul, city: Pune, email: [email protected]
customer_id: 2, name: Neha, city: NULL, email: [email protected]
customer_id: 3, name: Aman, city: Delhi, email: NULL
🚫 Biggest Beginner Mistake
❌ This is WRONG
SELECT * FROM customers WHERE city = NULL;
👉 This will return no rows
Why? Because NULL cannot be compared using = or !=
✅ Correct Way to Handle NULL
1️⃣ IS NULL: Used to find missing values
SELECT * FROM customers WHERE city IS NULL;
What this query does:
- Scans all rows
- Returns customers where city is missing
2️⃣ IS NOT NULL: Used to exclude missing values
SELECT * FROM customers WHERE email IS NOT NULL;
What this query does:
- Returns customers who have email
- Removes rows with NULL email
NULLs in JOINs (Very Important)
Customers data:
customer_id: 1, name: Rahul
customer_id: 2, name: Neha
customer_id: 3, name: Aman
Orders data:
order_id: 101, customer_id: 1, amount: 5000
order_id: 102, customer_id: 1, amount: 3000
LEFT JOIN with NULL check
👉 Find customers with NO orders
SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.customer_id IS NULL;
What this query does:
- Keeps all customers
- Matches orders where possible
- Filters customers without orders
NULLs in Aggregations
COUNT behavior (INTERVIEW FAVORITE)
SELECT COUNT(*) FROM customers;
👉 Counts all rows
SELECT COUNT(city) FROM customers;
👉 Counts only non-NULL cities
Example
SELECT COUNT(email) FROM customers;
✔ Counts customers who have email
❌ Ignores NULL emails
Handling NULL using COALESCE
SELECT name, COALESCE(city, 'Unknown') AS city
FROM customers;
What this query does:
- If city exists → show city
- If city is NULL → show “Unknown”
NULLs in SUM / AVG
SELECT SUM(amount) FROM orders;
👉 NULL values are ignored, not treated as 0
But if all rows are NULL, result is NULL.
Safe approach:
SELECT COALESCE(SUM(amount), 0) FROM orders;
NULL vs Empty String
- NULL: No value
- '': Empty value
WHERE email IS NULL -- missing
WHERE email = '' -- empty but exists
Common NULL Mistakes (Must Avoid)
❌ Using = NULL
❌ Forgetting NULLs in LEFT JOIN
❌ Assuming COUNT(column) counts NULL
❌ Ignoring NULL replacement in reports
Interview One-Liner 💡
> NULL represents missing data and must be handled using IS NULL, IS NOT NULL, or COALESCE, not with =.
Double Tap ♥️ For More
❤10
What does NULL represent in SQL?
Anonymous Quiz
13%
A. Zero
40%
B. Empty string
3%
C. False value
44%
D. Missing or unknown value
👍5❤2
Here are some commonly asked SQL interview questions along with brief answers:
1. What is SQL?
- SQL stands for Structured Query Language, used for managing and manipulating relational databases.
2. What are the types of SQL commands?
- SQL commands can be broadly categorized into four types: Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL).
3. What is the difference between CHAR and VARCHAR data types?
- CHAR is a fixed-length character data type, while VARCHAR is a variable-length character data type. CHAR will always occupy the same amount of storage space, while VARCHAR will only use the necessary space to store the actual data.
4. What is a primary key?
- A primary key is a column or a set of columns that uniquely identifies each row in a table. It ensures data integrity by enforcing uniqueness and can be used to establish relationships between tables.
5. What is a foreign key?
- A foreign key is a column or a set of columns in one table that refers to the primary key in another table. It establishes a relationship between two tables and ensures referential integrity.
6. What is a JOIN in SQL?
- JOIN is used to combine rows from two or more tables based on a related column between them. There are different types of JOINs, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
7. What is the difference between INNER JOIN and OUTER JOIN?
- INNER JOIN returns only the rows that have matching values in both tables, while OUTER JOIN (LEFT, RIGHT, FULL) returns all rows from one or both tables, with NULL values in columns where there is no match.
8. What is the difference between GROUP BY and ORDER BY?
- GROUP BY is used to group rows that have the same values into summary rows, typically used with aggregate functions like SUM, COUNT, AVG, etc., while ORDER BY is used to sort the result set based on one or more columns.
9. What is a subquery?
- A subquery is a query nested within another query, used to return data that will be used in the main query. Subqueries can be used in SELECT, INSERT, UPDATE, and DELETE statements.
10. What is normalization in SQL?
- Normalization is the process of organizing data in a database to reduce redundancy and dependency. It involves dividing large tables into smaller tables and defining relationships between them to improve data integrity and efficiency.
Around 90% questions will be asked from sql in data analytics interview, so please make sure to practice SQL skills using websites like stratascratch. ☺️💪
1. What is SQL?
- SQL stands for Structured Query Language, used for managing and manipulating relational databases.
2. What are the types of SQL commands?
- SQL commands can be broadly categorized into four types: Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL).
3. What is the difference between CHAR and VARCHAR data types?
- CHAR is a fixed-length character data type, while VARCHAR is a variable-length character data type. CHAR will always occupy the same amount of storage space, while VARCHAR will only use the necessary space to store the actual data.
4. What is a primary key?
- A primary key is a column or a set of columns that uniquely identifies each row in a table. It ensures data integrity by enforcing uniqueness and can be used to establish relationships between tables.
5. What is a foreign key?
- A foreign key is a column or a set of columns in one table that refers to the primary key in another table. It establishes a relationship between two tables and ensures referential integrity.
6. What is a JOIN in SQL?
- JOIN is used to combine rows from two or more tables based on a related column between them. There are different types of JOINs, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
7. What is the difference between INNER JOIN and OUTER JOIN?
- INNER JOIN returns only the rows that have matching values in both tables, while OUTER JOIN (LEFT, RIGHT, FULL) returns all rows from one or both tables, with NULL values in columns where there is no match.
8. What is the difference between GROUP BY and ORDER BY?
- GROUP BY is used to group rows that have the same values into summary rows, typically used with aggregate functions like SUM, COUNT, AVG, etc., while ORDER BY is used to sort the result set based on one or more columns.
9. What is a subquery?
- A subquery is a query nested within another query, used to return data that will be used in the main query. Subqueries can be used in SELECT, INSERT, UPDATE, and DELETE statements.
10. What is normalization in SQL?
- Normalization is the process of organizing data in a database to reduce redundancy and dependency. It involves dividing large tables into smaller tables and defining relationships between them to improve data integrity and efficiency.
Around 90% questions will be asked from sql in data analytics interview, so please make sure to practice SQL skills using websites like stratascratch. ☺️💪
❤4
Which condition correctly finds rows where city is missing?
Anonymous Quiz
27%
A. city = NULL
11%
B. city != NULL
56%
C. city IS NULL
6%
D. city = ''
❤3
What is the result of this query?
SELECT COUNT(city) FROM customers;
SELECT COUNT(city) FROM customers;
Anonymous Quiz
28%
A. Counts all rows
12%
B. Counts only rows where city is NULL
55%
C. Counts only rows where city is NOT NULL
4%
D. Returns error
❤2
You want to show 0 instead of NULL for total sales. Which function should you use?
Anonymous Quiz
33%
A. ISNULL
8%
B. NVL
46%
C. COALESCE
13%
D. NULLIF
❤3
In a LEFT JOIN, why do unmatched rows show NULL values?
Anonymous Quiz
4%
A. Because data is deleted
5%
B. Because INNER JOIN is used
78%
C. Because matching rows don’t exist in the right table
14%
D. Because NULL is a default value
❤3
SQL Interview Questions for 0-1 year of Experience (Asked in Top Product-Based Companies).
Sharpen your SQL skills with these real interview questions!
Q1. Customer Purchase Patterns -
You have two tables, Customers and Purchases: CREATE TABLE Customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(255) ); CREATE TABLE Purchases ( purchase_id INT PRIMARY KEY, customer_id INT, product_id INT, purchase_date DATE );
Assume necessary INSERT statements are already executed.
Write an SQL query to find the names of customers who have purchased more than 5 different products within the last month. Order the result by customer_name.
Q2. Call Log Analysis -
Suppose you have a CallLogs table: CREATE TABLE CallLogs ( log_id INT PRIMARY KEY, caller_id INT, receiver_id INT, call_start_time TIMESTAMP, call_end_time TIMESTAMP );
Assume necessary INSERT statements are already executed.
Write a query to find the average call duration per user. Include only users who have made more than 10 calls in total. Order the result by average duration descending.
Q3. Employee Project Allocation - Consider two tables, Employees and Projects:
CREATE TABLE Employees ( employee_id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(255) ); CREATE TABLE Projects ( project_id INT PRIMARY KEY, lead_employee_id INT, project_name VARCHAR(255), start_date DATE, end_date DATE );
Assume necessary INSERT statements are already executed.
The goal is to write an SQL query to find the names of employees who have led more than 3 projects in the last year. The result should be ordered by the number of projects led.
Sharpen your SQL skills with these real interview questions!
Q1. Customer Purchase Patterns -
You have two tables, Customers and Purchases: CREATE TABLE Customers ( customer_id INT PRIMARY KEY, customer_name VARCHAR(255) ); CREATE TABLE Purchases ( purchase_id INT PRIMARY KEY, customer_id INT, product_id INT, purchase_date DATE );
Assume necessary INSERT statements are already executed.
Write an SQL query to find the names of customers who have purchased more than 5 different products within the last month. Order the result by customer_name.
Q2. Call Log Analysis -
Suppose you have a CallLogs table: CREATE TABLE CallLogs ( log_id INT PRIMARY KEY, caller_id INT, receiver_id INT, call_start_time TIMESTAMP, call_end_time TIMESTAMP );
Assume necessary INSERT statements are already executed.
Write a query to find the average call duration per user. Include only users who have made more than 10 calls in total. Order the result by average duration descending.
Q3. Employee Project Allocation - Consider two tables, Employees and Projects:
CREATE TABLE Employees ( employee_id INT PRIMARY KEY, employee_name VARCHAR(255), department VARCHAR(255) ); CREATE TABLE Projects ( project_id INT PRIMARY KEY, lead_employee_id INT, project_name VARCHAR(255), start_date DATE, end_date DATE );
Assume necessary INSERT statements are already executed.
The goal is to write an SQL query to find the names of employees who have led more than 3 projects in the last year. The result should be ordered by the number of projects led.
❤4