๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐๐
๐ฐ๐ฒ๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐ | ๐ฑ ๐ฃ๐ผ๐๐ฒ๐ฟ๐ณ๐๐น ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
๐ฅ Top 5 FREE Excel Courses:
1๏ธโฃ Goldman Sachs โ Excel Skills for Business
2๏ธโฃ PwC โ Problem Solving with Excel
3๏ธโฃ Corporate Finance Institute โ Excel Fundamentals
4๏ธโฃ Great Learning โ Excel for Beginners
5๏ธโฃ Simplilearn โ Introduction to MS Excel
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/3UQ8S09
๐ Learn Excel for FREE and upgrade your career skills!
๐ฅ Top 5 FREE Excel Courses:
1๏ธโฃ Goldman Sachs โ Excel Skills for Business
2๏ธโฃ PwC โ Problem Solving with Excel
3๏ธโฃ Corporate Finance Institute โ Excel Fundamentals
4๏ธโฃ Great Learning โ Excel for Beginners
5๏ธโฃ Simplilearn โ Introduction to MS Excel
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/3UQ8S09
๐ Learn Excel for FREE and upgrade your career skills!
โค4
Scenario based Interview Questions & Answers for Data Analyst
1. Scenario: You are working on a SQL database that stores customer information. The database has a table called "Orders" that contains order details. Your task is to write a SQL query to retrieve the total number of orders placed by each customer.
Question:
- Write a SQL query to find the total number of orders placed by each customer.
Expected Answer:
SELECT CustomerID, COUNT(*) AS TotalOrders
FROM Orders
GROUP BY CustomerID;
2. Scenario: You are working on a SQL database that stores employee information. The database has a table called "Employees" that contains employee details. Your task is to write a SQL query to retrieve the names of all employees who have been with the company for more than 5 years.
Question:
- Write a SQL query to find the names of employees who have been with the company for more than 5 years.
Expected Answer:
SELECT Name
FROM Employees
WHERE DATEDIFF(year, HireDate, GETDATE()) > 5;
Power BI Scenario-Based Questions
1. Scenario: You have been given a dataset in Power BI that contains sales data for a company. Your task is to create a report that shows the total sales by product category and region.
Expected Answer:
- Load the dataset into Power BI.
- Create relationships if necessary.
- Use the "Fields" pane to select the necessary fields (Product Category, Region, Sales).
- Drag these fields into the "Values" area of a new visualization (e.g., a table or bar chart).
- Use the "Filters" pane to filter data as needed.
- Format the visualization to enhance clarity and readability.
2. Scenario: You have been asked to create a Power BI dashboard that displays real-time stock prices for a set of companies. The stock prices are available through an API.
Expected Answer:
- Use Power BI Desktop to connect to the API.
- Go to "Get Data" > "Web" and enter the API URL.
- Configure the data refresh settings to ensure real-time updates (e.g., setting up a scheduled refresh or using DirectQuery if supported).
- Create visualizations using the imported data.
- Publish the report to the Power BI service and set up a data gateway if needed for continuous refresh.
3. Scenario: You have been given a Power BI report that contains multiple visualizations. The report is taking a long time to load and is impacting the performance of the application.
Expected Answer:
- Analyze the current performance using Performance Analyzer.
- Optimize data model by reducing the number of columns and rows, and removing unnecessary calculations.
- Use aggregated tables to pre-compute results.
- Simplify DAX calculations.
- Optimize visualizations by reducing the number of visuals per page and avoiding complex custom visuals.
- Ensure proper indexing on the data source.
Free SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like if you need more similar content
Hope it helps :)
1. Scenario: You are working on a SQL database that stores customer information. The database has a table called "Orders" that contains order details. Your task is to write a SQL query to retrieve the total number of orders placed by each customer.
Question:
- Write a SQL query to find the total number of orders placed by each customer.
Expected Answer:
SELECT CustomerID, COUNT(*) AS TotalOrders
FROM Orders
GROUP BY CustomerID;
2. Scenario: You are working on a SQL database that stores employee information. The database has a table called "Employees" that contains employee details. Your task is to write a SQL query to retrieve the names of all employees who have been with the company for more than 5 years.
Question:
- Write a SQL query to find the names of employees who have been with the company for more than 5 years.
Expected Answer:
SELECT Name
FROM Employees
WHERE DATEDIFF(year, HireDate, GETDATE()) > 5;
Power BI Scenario-Based Questions
1. Scenario: You have been given a dataset in Power BI that contains sales data for a company. Your task is to create a report that shows the total sales by product category and region.
Expected Answer:
- Load the dataset into Power BI.
- Create relationships if necessary.
- Use the "Fields" pane to select the necessary fields (Product Category, Region, Sales).
- Drag these fields into the "Values" area of a new visualization (e.g., a table or bar chart).
- Use the "Filters" pane to filter data as needed.
- Format the visualization to enhance clarity and readability.
2. Scenario: You have been asked to create a Power BI dashboard that displays real-time stock prices for a set of companies. The stock prices are available through an API.
Expected Answer:
- Use Power BI Desktop to connect to the API.
- Go to "Get Data" > "Web" and enter the API URL.
- Configure the data refresh settings to ensure real-time updates (e.g., setting up a scheduled refresh or using DirectQuery if supported).
- Create visualizations using the imported data.
- Publish the report to the Power BI service and set up a data gateway if needed for continuous refresh.
3. Scenario: You have been given a Power BI report that contains multiple visualizations. The report is taking a long time to load and is impacting the performance of the application.
Expected Answer:
- Analyze the current performance using Performance Analyzer.
- Optimize data model by reducing the number of columns and rows, and removing unnecessary calculations.
- Use aggregated tables to pre-compute results.
- Simplify DAX calculations.
- Optimize visualizations by reducing the number of visuals per page and avoiding complex custom visuals.
- Ensure proper indexing on the data source.
Free SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
Like if you need more similar content
Hope it helps :)
โค7
๐ ๐๐ฒ๐๐ฒ๐น ๐จ๐ฝ ๐ฌ๐ผ๐๐ฟ ๐๐ฎ๐ฟ๐ฒ๐ฒ๐ฟ ๐๐ถ๐๐ต ๐๐ฅ๐๐ ๐ ๐ถ๐ฐ๐ฟ๐ผ๐๐ผ๐ณ๐ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด! ๐ป
Microsoft-focused learning paths can help you strengthen your resume and prepare for in-demand tech and data roles.
๐ฅ Top 5 Courses / Certification Paths:
โ Beginner-friendly options
โ Build practical, job-ready skills
โ Learn Azure, Power BI, Excel & SQL
โ Strengthen your resume & career profile
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/3UNpPs7
๐ซPerfect for students, freshers, data analysts and professionals looking to upgrade their skills.
Microsoft-focused learning paths can help you strengthen your resume and prepare for in-demand tech and data roles.
๐ฅ Top 5 Courses / Certification Paths:
โ Beginner-friendly options
โ Build practical, job-ready skills
โ Learn Azure, Power BI, Excel & SQL
โ Strengthen your resume & career profile
๐๐ป๐ฟ๐ผ๐น๐น ๐๐ผ๐ฟ ๐๐ฅ๐๐๐:-
https://pdlink.in/3UNpPs7
๐ซPerfect for students, freshers, data analysts and professionals looking to upgrade their skills.
โค7
๐ ๐ง๐ผ๐ฝ ๐๐ผ๐บ๐ฝ๐ฎ๐ป๐ถ๐ฒ๐ ๐ข๐ณ๐ณ๐ฒ๐ฟ๐ถ๐ป๐ด ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐
Learn in-demand skills โข Add valuable credentials to your resume
๐ข TATA :- https://pdlink.in/3QiwLvx
๐ป Infosys :- https://pdlink.in/4eBH3Aa
โก IBM :- https://pdlink.in/45KgqDR
๐ซ Amazon :- https://pdlink.in/47XuBGz
๐ Cisco :- https://pdlink.in/4gaeVVV
๐ช Microsoft :- https://pdlink.in/4zhGTX6
๐ข Save & share this with your friends โ start upskilling for FREE!
Learn in-demand skills โข Add valuable credentials to your resume
๐ข TATA :- https://pdlink.in/3QiwLvx
๐ป Infosys :- https://pdlink.in/4eBH3Aa
โก IBM :- https://pdlink.in/45KgqDR
๐ซ Amazon :- https://pdlink.in/47XuBGz
๐ Cisco :- https://pdlink.in/4gaeVVV
๐ช Microsoft :- https://pdlink.in/4zhGTX6
๐ข Save & share this with your friends โ start upskilling for FREE!
โค1
๐ Data Analyst Roadmap โ Part 16
๐ง SQL Level 6 โ Window Functions
Window functions are one of the most important SQL skills for a Data Analyst.
They allow you to perform calculations across related rows without losing the individual rows.
Instead of collapsing data like GROUP BY, window functions let you analyze each row in the context of other rows.
๐น 1. GROUP BY vs Window Functions
Suppose you have:
With GROUP BY:
You get one row per department.
With a window function:
You keep every employee while also seeing their department's average salary.
๐ GROUP BY reduces rows.
๐ Window functions preserve rows.
๐น 2. Understanding OVER()
Every window function uses the OVER() clause.
The three important concepts are:
โข OVER() โ Defines the window.
โข PARTITION BY โ Divides rows into groups.
โข ORDER BY โ Defines the order inside each group.
๐น 3. ROW_NUMBER()
Assigns a unique sequential number to each row.
Result:
โ ๏ธ If salaries are tied, ROW_NUMBER() still assigns different numbers.
๐น 4. RANK()
Gives the same rank to tied values.
For: 100, 100, 90
RANK() produces: 1, 1, 3
The next rank is skipped.
๐น 5. DENSE_RANK()
Also gives the same rank to tied values, but doesn't skip the next rank.
For: 100, 100, 90
DENSE_RANK() produces: 1, 1, 2
๐ง Remember the Difference
For values: 100, 100, 90, 80
This difference is a very common SQL interview topic.
๐น 6. Overall Ranking
Remove PARTITION BY when you want to rank across the entire dataset.
๐น 7. Top N Employees Per Department
One of the most useful real-world applications.
This finds the top 2 employees in every department.
This pattern is extremely important:
Window Function โ CTE/Subquery โ Filter
๐น 8. LAG()
LAG() lets you access a value from a previous row.
For monthly sales:
๐ง SQL Level 6 โ Window Functions
Window functions are one of the most important SQL skills for a Data Analyst.
They allow you to perform calculations across related rows without losing the individual rows.
Instead of collapsing data like GROUP BY, window functions let you analyze each row in the context of other rows.
๐น 1. GROUP BY vs Window Functions
Suppose you have:
Employee | Department | Salary
John | IT | 75,000
Mike | IT | 90,000
Lisa | IT | 90,000
Sarah | HR | 60,000
Alice | HR | 70,000
With GROUP BY:
SELECT Department, AVG(Salary) AS Avg_Salary
FROM Employees
GROUP BY Department;
You get one row per department.
With a window function:
SELECT
Employee,
Department,
Salary,
AVG(Salary) OVER (PARTITION BY Department) AS Avg_Dept_Salary
FROM Employees;
You keep every employee while also seeing their department's average salary.
๐ GROUP BY reduces rows.
๐ Window functions preserve rows.
๐น 2. Understanding OVER()
Every window function uses the OVER() clause.
FUNCTION() OVER (
PARTITION BY column
ORDER BY column
)
The three important concepts are:
โข OVER() โ Defines the window.
โข PARTITION BY โ Divides rows into groups.
โข ORDER BY โ Defines the order inside each group.
๐น 3. ROW_NUMBER()
Assigns a unique sequential number to each row.
SELECT
Employee,
Department,
Salary,
ROW_NUMBER() OVER (
PARTITION BY Department
ORDER BY Salary DESC
) AS Row_Num
FROM Employees;
Result:
Employee | Department | Salary | Row_Num
Mike | IT | 90,000 | 1
Lisa | IT | 90,000 | 2
John | IT | 75,000 | 3
Alice | HR | 70,000 | 1
Sarah | HR | 60,000 | 2
โ ๏ธ If salaries are tied, ROW_NUMBER() still assigns different numbers.
๐น 4. RANK()
Gives the same rank to tied values.
For: 100, 100, 90
RANK() produces: 1, 1, 3
The next rank is skipped.
RANK() OVER (
PARTITION BY Department
ORDER BY Salary DESC
) AS Salary_Rank
๐น 5. DENSE_RANK()
Also gives the same rank to tied values, but doesn't skip the next rank.
For: 100, 100, 90
DENSE_RANK() produces: 1, 1, 2
๐ง Remember the Difference
For values: 100, 100, 90, 80
Function | Result
ROW_NUMBER() | 1, 2, 3, 4
RANK() | 1, 1, 3, 4
DENSE_RANK() | 1, 1, 2, 3
This difference is a very common SQL interview topic.
๐น 6. Overall Ranking
Remove PARTITION BY when you want to rank across the entire dataset.
SELECT
Employee,
Salary,
RANK() OVER (
ORDER BY Salary DESC
) AS Overall_Rank
FROM Employees;
๐น 7. Top N Employees Per Department
One of the most useful real-world applications.
WITH Ranked_Employees AS (
SELECT
Employee,
Department,
Salary,
ROW_NUMBER() OVER (
PARTITION BY Department
ORDER BY Salary DESC
) AS rn
FROM Employees
)
SELECT
Employee,
Department,
Salary
FROM Ranked_Employees
WHERE rn <= 2;
This finds the top 2 employees in every department.
This pattern is extremely important:
Window Function โ CTE/Subquery โ Filter
๐น 8. LAG()
LAG() lets you access a value from a previous row.
For monthly sales:
Month | Sales
Jan | 10,000
Feb | 12,000
Mar | 15,000
SELECT
Sales_Month,
Sales,
LAG(Sales) OVER (
ORDER BY Sales_Month
) AS Previous_Month_Sales
FROM Monthly_Sales;
โค2
You can then calculate month-over-month change:
๐น 9. LEAD()
LEAD() does the opposite.
It allows you to access the next row.
Useful for:
โข Comparing future periods
โข Customer activity
โข Event sequences
โข Next purchase analysis
โข Time-based analysis
๐น 10. Running Total
A running total continuously accumulates values.
Example: 10,000 โ 15,000 โ 22,000 becomes 10,000 โ 25,000 โ 47,000
๐น 11. Running Total by Region
You can combine PARTITION BY with a running total.
Each region gets its own running total.
๐น 12. Moving Average
A moving average helps identify trends while reducing short-term fluctuations.
This calculates a 3-month moving average.
Useful for:
๐ Sales trends,
๐ Revenue analysis,
๐ฆ Demand forecasting,
๐ฅ Customer activity
๐น 13. NTILE()
NTILE() divides rows into approximately equal groups.
For example, divide customers into four sales groups:
This can help identify:
โข Top 25% customers
โข Bottom 25% customers
โข Customer segments
โข Performance groups
๐น 14. Removing Duplicates
Window functions are also extremely useful for deduplication.
This keeps the first record from each duplicate group.
๐น 15. Why Window Functions Cannot Usually Be Used Directly in WHERE
This won't generally work:
Why?
Because the window calculation happens after the filtering stage.
Instead, use a CTE:
This is another reason CTEs + Window Functions are such a powerful combination.
๐ผ Real-World Data Analyst Applications
Window functions are commonly used for:
โ Top N products by category
โ Ranking employees by department
โ Customer rankings by region
โ Month-over-month growth
โ Running revenue totals
โ Moving averages
โ Finding first/previous/next transactions
โ Identifying duplicate records
โ Customer purchase sequences
โ Performance comparisons
๐ฏ SQL Interview Challenge
Question: Find the top 3 highest-paid employees in every department.
๐ Double Tap โค๏ธ For More
SELECT
Sales_Month,
Sales,
Sales - LAG(Sales) OVER (
ORDER BY Sales_Month
) AS Sales_Change
FROM Monthly_Sales;
๐น 9. LEAD()
LEAD() does the opposite.
It allows you to access the next row.
SELECT
Sales_Month,
Sales,
LEAD(Sales) OVER (
ORDER BY Sales_Month
) AS Next_Month_Sales
FROM Monthly_Sales;
Useful for:
โข Comparing future periods
โข Customer activity
โข Event sequences
โข Next purchase analysis
โข Time-based analysis
๐น 10. Running Total
A running total continuously accumulates values.
SELECT
Order_Date,
Sales,
SUM(Sales) OVER (
ORDER BY Order_Date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS Running_Sales
FROM Orders;
Example: 10,000 โ 15,000 โ 22,000 becomes 10,000 โ 25,000 โ 47,000
๐น 11. Running Total by Region
You can combine PARTITION BY with a running total.
SELECT
Region,
Order_Date,
Sales,
SUM(Sales) OVER (
PARTITION BY Region
ORDER BY Order_Date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS Regional_Running_Sales
FROM Orders;
Each region gets its own running total.
๐น 12. Moving Average
A moving average helps identify trends while reducing short-term fluctuations.
SELECT
Sales_Month,
Sales,
AVG(Sales) OVER (
ORDER BY Sales_Month
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
) AS Three_Month_Avg
FROM Monthly_Sales;
This calculates a 3-month moving average.
Useful for:
๐ Sales trends,
๐ Revenue analysis,
๐ฆ Demand forecasting,
๐ฅ Customer activity
๐น 13. NTILE()
NTILE() divides rows into approximately equal groups.
For example, divide customers into four sales groups:
SELECT
Customer_ID,
Total_Sales,
NTILE(4) OVER (
ORDER BY Total_Sales DESC
) AS Sales_Quartile
FROM Customers;
This can help identify:
โข Top 25% customers
โข Bottom 25% customers
โข Customer segments
โข Performance groups
๐น 14. Removing Duplicates
Window functions are also extremely useful for deduplication.
WITH Ranked_Data AS (
SELECT
*,
ROW_NUMBER() OVER (
PARTITION BY Customer_ID, Order_Date, Sales
ORDER BY Order_ID
) AS rn
FROM Orders
)
SELECT *
FROM Ranked_Data
WHERE rn = 1;
This keeps the first record from each duplicate group.
๐น 15. Why Window Functions Cannot Usually Be Used Directly in WHERE
This won't generally work:
SELECT
Employee,
RANK() OVER (ORDER BY Salary DESC) AS Salary_Rank
FROM Employees
WHERE Salary_Rank <= 3;
Why?
Because the window calculation happens after the filtering stage.
Instead, use a CTE:
WITH Ranked AS (
SELECT
Employee,
Salary,
RANK() OVER (
ORDER BY Salary DESC
) AS Salary_Rank
FROM Employees
)
SELECT *
FROM Ranked
WHERE Salary_Rank <= 3;
This is another reason CTEs + Window Functions are such a powerful combination.
๐ผ Real-World Data Analyst Applications
Window functions are commonly used for:
โ Top N products by category
โ Ranking employees by department
โ Customer rankings by region
โ Month-over-month growth
โ Running revenue totals
โ Moving averages
โ Finding first/previous/next transactions
โ Identifying duplicate records
โ Customer purchase sequences
โ Performance comparisons
๐ฏ SQL Interview Challenge
Question: Find the top 3 highest-paid employees in every department.
WITH Ranked_Employees AS (
SELECT
Employee,
Department,
Salary,
DENSE_RANK() OVER (
PARTITION BY Department
ORDER BY Salary DESC
) AS Salary_Rank
FROM Employees
)
SELECT
Employee,
Department,
Salary
FROM Ranked_Employees
WHERE Salary_Rank <= 3;
๐ Double Tap โค๏ธ For More
โค14๐ฅ2
๐ ๐๐ฟ๐ฒ๐ฎ๐บ๐ถ๐ป๐ด ๐ผ๐ณ ๐ช๐ผ๐ฟ๐ธ๐ถ๐ป๐ด ๐ฎ๐ ๐ง๐ผ๐ฝ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐บ๐ฝ๐ฎ๐ป๐ถ๐ฒ๐? ๐ป๐ฅ
Hereโs a collection of company-specific resources to help you understand their interview and hiring processes.
๐ฏ Interview Preparation Guides For:
๐ Amazon โ Interviewing Guide
๐ต Google โ Interview Tips
๐ช Microsoft โ Hiring & Interview Tips
๐ข NVIDIA โ Hiring Process
๐ท Meta โ Software Engineering Interview Prep
๐๐ข๐ง๐ค ๐:-
https://pdlink.in/4i6HkgN
๐ข Save & share this with your friends โ start learning for FREE!
Hereโs a collection of company-specific resources to help you understand their interview and hiring processes.
๐ฏ Interview Preparation Guides For:
๐ Amazon โ Interviewing Guide
๐ต Google โ Interview Tips
๐ช Microsoft โ Hiring & Interview Tips
๐ข NVIDIA โ Hiring Process
๐ท Meta โ Software Engineering Interview Prep
๐๐ข๐ง๐ค ๐:-
https://pdlink.in/4i6HkgN
๐ข Save & share this with your friends โ start learning for FREE!
โค4๐2๐1
๐ฅ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐ฆ๐ค๐ ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ โ ๐๐ฟ๐ผ๐บ ๐๐ฒ๐ด๐ถ๐ป๐ป๐ฒ๐ฟ ๐๐ผ ๐๐ฑ๐๐ฎ๐ป๐ฐ๐ฒ๐ฑ! ๐ป๐
These free learning resources cover everything from database fundamentals to advanced SQL queries, with opportunities to practice real-world problems.
๐ฏ Top FREE SQL Resources:
1๏ธโฃ Introduction to Databases & SQL โ Udemy
2๏ธโฃ Advanced Database & SQL โ Udemy
3๏ธโฃ Learn SQL โ Codecademy
4๏ธโฃ SQL Tutorial โ SQLZoo
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4gNYHk7
๐ Start from the basics and work your way toward advanced SQL skills!
These free learning resources cover everything from database fundamentals to advanced SQL queries, with opportunities to practice real-world problems.
๐ฏ Top FREE SQL Resources:
1๏ธโฃ Introduction to Databases & SQL โ Udemy
2๏ธโฃ Advanced Database & SQL โ Udemy
3๏ธโฃ Learn SQL โ Codecademy
4๏ธโฃ SQL Tutorial โ SQLZoo
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4gNYHk7
๐ Start from the basics and work your way toward advanced SQL skills!
Which window function assigns unique sequential numbers to rows, even when values are tied?
Anonymous Quiz
21%
A) RANK()
35%
B) DENSE_RANK()
39%
C) ROW_NUMBER()
4%
D) NTILE()
โค3
Which statement correctly describes GROUP BY vs Window Functions?
Anonymous Quiz
10%
A) Both always produce the same number of rows
10%
B) GROUP BY preserves every individual row
12%
C) Window functions collapse rows into groups
68%
D) GROUP BY can reduce rows, while window functions preserve row-level detail
โค2
Which function is most appropriate for comparing a row's value with the previous row?
Anonymous Quiz
19%
A) LEAD()
39%
B) LAG()
35%
C) RANK()
6%
D) NTILE()
You need to find the top 3 employees in each department. Which approach is most appropriate?
Anonymous Quiz
14%
A) GROUP BY Department only
10%
B) ORDER BY Salary DESC only
73%
C) RANK() OVER (PARTITION BY Department ORDER BY Salary DESC) followed by filtering
4%
D) AVG(Salary) OVER () only
โค2
๐ฃ๐ฎ๐ ๐๐ณ๐๐ฒ๐ฟ ๐ฃ๐น๐ฎ๐ฐ๐ฒ๐บ๐ฒ๐ป๐ โ ๐๐ฒ๐ ๐ฃ๐น๐ฎ๐ฐ๐ฒ๐ฑ ๐๐ป ๐ง๐ผ๐ฝ ๐ง๐ฒ๐ฐ๐ต ๐๐ผ๐บ๐ฝ๐ฎ๐ป๐ถ๐ฒ๐๐
Learn JAVA/MERN Full Stack Development With GenAI.
๐ Placement Highlights:-
๐ฐ โน41 LPA highest salary
๐ โน7.4 LPA average salary
๐ 2,000+ students placed
๐ข 500+ partner companies
๐ ๐๐ฝ๐ฝ๐น๐ ๐ก๐ผ๐ ๐:-
https://pdlink.in/3SuUeuD
โก Take the first step toward your dream tech career today!
Learn JAVA/MERN Full Stack Development With GenAI.
๐ Placement Highlights:-
๐ฐ โน41 LPA highest salary
๐ โน7.4 LPA average salary
๐ 2,000+ students placed
๐ข 500+ partner companies
๐ ๐๐ฝ๐ฝ๐น๐ ๐ก๐ผ๐ ๐:-
https://pdlink.in/3SuUeuD
โก Take the first step toward your dream tech career today!
โค2
๐ ๐๐ฅ๐๐ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐๐ผ๐๐ฟ๐๐ฒ ๐ข๐ป ๐๐๐๐ฟ๐ฒ ๐ ๐ฎ๐ฐ๐ต๐ถ๐ป๐ฒ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด โ๏ธ
โจ Build practical skills in Cloud AI โข Machine Learning โข Data Preparation โข ML Workflows โข Azure Data Services.
๐ฅ Learn โ Practice โ Build Projects โ Strengthen Your Tech Career
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/3UyljxK
๐ Perfect for Students โข Freshers โข Data Science Aspirants โข AI/ML Learners โข Working Professionals
โจ Build practical skills in Cloud AI โข Machine Learning โข Data Preparation โข ML Workflows โข Azure Data Services.
๐ฅ Learn โ Practice โ Build Projects โ Strengthen Your Tech Career
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/3UyljxK
๐ Perfect for Students โข Freshers โข Data Science Aspirants โข AI/ML Learners โข Working Professionals
๐1
๐ Data Analyst Roadmap โ Part 17
๐ง SQL Level 7 โ Date & Time Functions + Time-Based Analysis
Date and time analysis is one of the most important SQL skills for a Data Analyst.
Real business data is heavily time-dependent:
๐ Monthly revenue
๐ Year-over-year growth
๐ Daily orders
๐ฅ Customer activity
๐ฆ Product demand
โฑ๏ธ Response time
๐ Retention and cohort analysis
To become strong in SQL, you need to know how to extract, filter, compare, group, and calculate differences between dates.
๐น 1. Understanding Date & Time Data Types
โข DATE โ Date only
โข TIME โ Time only
โข DATETIME / TIMESTAMP โ Date + time
๐น 2. Extracting Parts of a Date
๐น 3. Grouping Sales by Year
๐น 4. Grouping Sales by Month
โ ๏ธ Don't group only by month number when data covers multiple years โ Jan 2025 + Jan 2026 would merge incorrectly.
๐น 5. Filtering Data by Date
๐น 6. Why Date Ranges Matter
If
Use half-open range:
๐น 7. Date Difference
Conceptually:
Dialects vary:
๐น 8. Customers Who Took >30 Days to Purchase
๐น 9. Adding / Subtracting Dates
๐น 10. Current Date and Time
๐น 11. Recent Orders (Last 30 Days)
๐น 12. Year-over-Year Analysis
Formula:
In SQL:
๐น 13. Month-over-Month Growth
๐น 14. Quarter Analysis
๐น 15. First and Last Transaction
๐ง SQL Level 7 โ Date & Time Functions + Time-Based Analysis
Date and time analysis is one of the most important SQL skills for a Data Analyst.
Real business data is heavily time-dependent:
๐ Monthly revenue
๐ Year-over-year growth
๐ Daily orders
๐ฅ Customer activity
๐ฆ Product demand
โฑ๏ธ Response time
๐ Retention and cohort analysis
To become strong in SQL, you need to know how to extract, filter, compare, group, and calculate differences between dates.
๐น 1. Understanding Date & Time Data Types
โข DATE โ Date only
โข TIME โ Time only
โข DATETIME / TIMESTAMP โ Date + time
Order_Date: 2026-01-15
Order_Timestamp: 2026-01-15 14:35:20
๐น 2. Extracting Parts of a Date
SELECT
Order_Date,
EXTRACT(YEAR FROM Order_Date) AS Order_Year,
EXTRACT(MONTH FROM Order_Date) AS Order_Month
FROM Orders;
๐น 3. Grouping Sales by Year
SELECT
EXTRACT(YEAR FROM Order_Date) AS Order_Year,
SUM(Sales) AS Total_Sales
FROM Orders
GROUP BY EXTRACT(YEAR FROM Order_Date)
ORDER BY Order_Year;
๐น 4. Grouping Sales by Month
SELECT
EXTRACT(YEAR FROM Order_Date) AS Order_Year,
EXTRACT(MONTH FROM Order_Date) AS Order_Month,
SUM(Sales) AS Total_Sales
FROM Orders
GROUP BY
EXTRACT(YEAR FROM Order_Date),
EXTRACT(MONTH FROM Order_Date)
ORDER BY Order_Year, Order_Month;
โ ๏ธ Don't group only by month number when data covers multiple years โ Jan 2025 + Jan 2026 would merge incorrectly.
๐น 5. Filtering Data by Date
SELECT * FROM Orders
WHERE Order_Date >= '2026-01-01'
AND Order_Date < '2026-02-01';
๐น 6. Why Date Ranges Matter
If
Order_Timestamp = 2026-01-31 23:30:00, thenWHERE Order_Timestamp <= '2026-01-31' will miss it.Use half-open range:
WHERE Order_Timestamp >= '2026-01-01'
AND Order_Timestamp < '2026-02-01'
๐น 7. Date Difference
Conceptually:
Date_Difference(First_Purchase_Date, Signup_Date)Dialects vary:
DATEDIFF(), DATE_DIFF(), subtraction, etc.๐น 8. Customers Who Took >30 Days to Purchase
SELECT Customer_ID, Signup_Date, First_Purchase_Date
FROM Customers
WHERE DATEDIFF(day, Signup_Date, First_Purchase_Date) > 30;
๐น 9. Adding / Subtracting Dates
Signup_Date + INTERVAL '30' DAY -- 30 days after signup
Order_Date - INTERVAL '7' DAY -- 7 days before order
๐น 10. Current Date and Time
CURRENT_DATE, CURRENT_TIMESTAMP โ useful for today's sales, active subs, overdue orders.๐น 11. Recent Orders (Last 30 Days)
SELECT * FROM Orders
WHERE Order_Date >= CURRENT_DATE - INTERVAL '30' DAY;
๐น 12. Year-over-Year Analysis
Formula:
(Current - Previous) / Previous * 100In SQL:
LAG(Sales) OVER (ORDER BY Year)
๐น 13. Month-over-Month Growth
WITH Monthly_Sales AS (
SELECT
EXTRACT(YEAR FROM Order_Date) AS Year,
EXTRACT(MONTH FROM Order_Date) AS Month,
SUM(Sales) AS Total_Sales
FROM Orders
GROUP BY 1, 2
)
SELECT
Year, Month, Total_Sales,
LAG(Total_Sales) OVER (ORDER BY Year, Month) AS Previous_Month_Sales
FROM Monthly_Sales;
๐น 14. Quarter Analysis
EXTRACT(QUARTER FROM Order_Date)
-- Q1: Jan-Mar, Q2: Apr-Jun, Q3: Jul-Sep, Q4: Oct-Dec
๐น 15. First and Last Transaction
ROW_NUMBER() OVER (
PARTITION BY Customer_ID
ORDER BY Order_Date
)
-- rn = 1 is first transaction
โค4
๐น 16. Days Between Purchases
๐น 17. Finding Inactive Customers
๐น 18. Common Mistake
Avoid:
Prefer: Range filter โ it's clearer and index-friendly.
๐ผ Real-World Applications
โ Monthly revenue, daily sales, YoY/MoM growth, retention, churn, purchase frequency, cohort, subscription expiry
๐ฏ SQL Interview Challenge: Find each customer's most recent order
๐ก Double Tap โค๏ธ For More
SELECT
Customer_ID, Order_Date,
LAG(Order_Date) OVER (PARTITION BY Customer_ID ORDER BY Order_Date) AS Previous_Order_Date
FROM Orders;
-- Then: Current - Previous
๐น 17. Finding Inactive Customers
SELECT Customer_ID, MAX(Order_Date) AS Last_Order_Date
FROM Orders
GROUP BY Customer_ID;
-- Compare with CURRENT_DATE for 90-day inactivity
๐น 18. Common Mistake
Avoid:
WHERE YEAR(Order_Date) = 2026Prefer: Range filter โ it's clearer and index-friendly.
๐ผ Real-World Applications
โ Monthly revenue, daily sales, YoY/MoM growth, retention, churn, purchase frequency, cohort, subscription expiry
๐ฏ SQL Interview Challenge: Find each customer's most recent order
WITH Ranked_Orders AS (
SELECT
Customer_ID, Order_ID, Order_Date,
ROW_NUMBER() OVER (PARTITION BY Customer_ID ORDER BY Order_Date DESC) AS rn
FROM Orders
)
SELECT Customer_ID, Order_ID, Order_Date
FROM Ranked_Orders
WHERE rn = 1;
๐ก Double Tap โค๏ธ For More
โค11
๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐๐ป-๐๐ฒ๐บ๐ฎ๐ป๐ฑ ๐ง๐ฒ๐ฐ๐ต ๐ฆ๐ธ๐ถ๐น๐น๐ ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐ถ๐ป ๐ฎ๐ฌ๐ฎ๐ฒ ๐ฅ
Want to upgrade your tech skills without spending money?
Here are some excellent FREE YouTube resources to learn high-demand technologies through tutorials and hands-on practice.
๐ฅ Learn โ Practice โ Build Projects โ Upgrade Your Resume
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4x3B9hb
๐ฏ Perfect for Students โข Freshers โข Job Seekers โข Working Professionals
Want to upgrade your tech skills without spending money?
Here are some excellent FREE YouTube resources to learn high-demand technologies through tutorials and hands-on practice.
๐ฅ Learn โ Practice โ Build Projects โ Upgrade Your Resume
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4x3B9hb
๐ฏ Perfect for Students โข Freshers โข Job Seekers โข Working Professionals
โค3๐2
Starting as a data analyst is a great first step in your career. As you grow, you might discover new interests:
โข If you love working with statistics and machine learning, you could move into Data Science.
โข If you're excited by building data systems and pipelines, Data Engineering might be your next step.
โข If you're more interested in understanding the business side, you could become a Business Analyst.
Even if you decide to stay in your data analyst role, there's always something new to learn, especially with advancements in AI.
There are many paths to explore, but what's important is taking that first step.
โข If you love working with statistics and machine learning, you could move into Data Science.
โข If you're excited by building data systems and pipelines, Data Engineering might be your next step.
โข If you're more interested in understanding the business side, you could become a Business Analyst.
Even if you decide to stay in your data analyst role, there's always something new to learn, especially with advancements in AI.
There are many paths to explore, but what's important is taking that first step.
โค9
๐ ๐๐ฅ๐๐ ๐๐ถ๐๐ถ ๐ฉ๐ถ๐ฟ๐๐๐ฎ๐น ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐ ๐ | Boost Your Resume
Citi offers virtual experience programs designed to help students and freshers develop job-ready skills through real-world tasks.
โ 100% FREE
โ Self-paced learning
โ Real-world projects
โ Certificate on completion
โ Add the experience to your Resume & LinkedIn
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4zZqJ4U
๐ฅ Learn โ Complete Projects โ Earn Certificate โ Strengthen Your Resume
Citi offers virtual experience programs designed to help students and freshers develop job-ready skills through real-world tasks.
โ 100% FREE
โ Self-paced learning
โ Real-world projects
โ Certificate on completion
โ Add the experience to your Resume & LinkedIn
๐ ๐๐ป๐ฟ๐ผ๐น๐น ๐ณ๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4zZqJ4U
๐ฅ Learn โ Complete Projects โ Earn Certificate โ Strengthen Your Resume
โค7
๐ Data Analyst Roadmap โ Part 18
๐ง SQL Level 8 โ Advanced Analytical Queries & Business Problems
At this stage, you know the core SQL building blocks:
โข SELECT โ WHERE โ GROUP BY โ HAVING โ JOIN โ CTE โ Window Functions โ Date Analysis
Now it's time to combine them.
Real Data Analyst work rarely asks:
โWrite a query using RANK().โ
Instead, you'll get business questions like:
โข Which customers are becoming inactive?
โข What are our top-selling products in each category?
โข
Which month had the highest revenue growth?
โข
The real skill is converting a business problem into SQL logic.
๐น 1. Start With the Business Question
Before writing SQL, identify:
โข What are we measuring?
โข At what level?
โข Which tables contain the required data?
โข What filters are needed?
โข Do we need aggregation?
โข Do we need ranking or comparison?
For example: โFind the top 3 products in every category.โ
Break it down:
โข Product โ Category โ Sales โ Rank within Category โ Keep Top 3
โข This approach prevents complicated SQL from becoming confusing.
๐น 2. Find the Correct Grain
One of the most important analytical concepts is grain.
Grain means: What does one row represent?
For example:
โข Orders โ one row per order
โข Order_Items โ one row per product within an order
โข
Customers โ one row per customer
โข
If you don't understand the grain, you can accidentally double-count revenue.
๐น 3. Revenue by Customer
Suppose you have:
Customers
โข Customer_ID
โข Customer_Name
and Orders
โข Order_ID
โข Customer_ID
โข Order_Date
โข Sales
You can calculate customer revenue:
โข Now you have one row per customer.
๐น 4. Rank Customers by Revenue
Combine aggregation with a window function:
โข This answers: Who are our highest-value customers?
๐น 5. Top 3 Customers in Each Region
Now add another business dimension.
โข This is a classic advanced SQL interview problem.
๐น 6. Finding the Second-Highest Salary
A common interview question.
โข Using DENSE_RANK() is useful when multiple employees share the same salary.
๐น 7. Find Products That Never Sold
This is a classic LEFT JOIN problem.
Business interpretation: Products exist in the catalog but have no sales.
This could indicate:
โข Poor demand
โข Pricing problems
โข Inventory issues
โข Product visibility problems
๐น 8. Customers With No Orders
The same logic can identify customers who have never purchased.
๐ง SQL Level 8 โ Advanced Analytical Queries & Business Problems
At this stage, you know the core SQL building blocks:
โข SELECT โ WHERE โ GROUP BY โ HAVING โ JOIN โ CTE โ Window Functions โ Date Analysis
Now it's time to combine them.
Real Data Analyst work rarely asks:
โWrite a query using RANK().โ
Instead, you'll get business questions like:
โข Which customers are becoming inactive?
โข What are our top-selling products in each category?
โข
Which month had the highest revenue growth?
โข
The real skill is converting a business problem into SQL logic.
๐น 1. Start With the Business Question
Before writing SQL, identify:
โข What are we measuring?
โข At what level?
โข Which tables contain the required data?
โข What filters are needed?
โข Do we need aggregation?
โข Do we need ranking or comparison?
For example: โFind the top 3 products in every category.โ
Break it down:
โข Product โ Category โ Sales โ Rank within Category โ Keep Top 3
โข This approach prevents complicated SQL from becoming confusing.
๐น 2. Find the Correct Grain
One of the most important analytical concepts is grain.
Grain means: What does one row represent?
For example:
โข Orders โ one row per order
โข Order_Items โ one row per product within an order
โข
Customers โ one row per customer
โข
If you don't understand the grain, you can accidentally double-count revenue.
๐น 3. Revenue by Customer
Suppose you have:
Customers
โข Customer_ID
โข Customer_Name
and Orders
โข Order_ID
โข Customer_ID
โข Order_Date
โข Sales
You can calculate customer revenue:
SELECT
c.Customer_ID,
c.Customer_Name,
SUM(o.Sales) AS Total_Sales
FROM Customers c
JOIN Orders o
ON c.Customer_ID = o.Customer_ID
GROUP BY
c.Customer_ID,
c.Customer_Name;
โข Now you have one row per customer.
๐น 4. Rank Customers by Revenue
Combine aggregation with a window function:
WITH Customer_Sales AS (
SELECT
Customer_ID,
SUM(Sales) AS Total_Sales
FROM Orders
GROUP BY Customer_ID
)
SELECT
Customer_ID,
Total_Sales,
RANK() OVER (ORDER BY Total_Sales DESC) AS Sales_Rank
FROM Customer_Sales;
โข This answers: Who are our highest-value customers?
๐น 5. Top 3 Customers in Each Region
Now add another business dimension.
WITH Customer_Sales AS (
SELECT Customer_ID, Region, SUM(Sales) AS Total_Sales
FROM Orders
GROUP BY Customer_ID, Region
),
Ranked_Customers AS (
SELECT
Customer_ID, Region, Total_Sales,
RANK() OVER (PARTITION BY Region ORDER BY Total_Sales DESC) AS Sales_Rank
FROM Customer_Sales
)
SELECT * FROM Ranked_Customers WHERE Sales_Rank <= 3;
โข This is a classic advanced SQL interview problem.
๐น 6. Finding the Second-Highest Salary
A common interview question.
WITH Ranked_Employees AS (
SELECT Employee, Salary,
DENSE_RANK() OVER (ORDER BY Salary DESC) AS Salary_Rank
FROM Employees
)
SELECT Employee, Salary FROM Ranked_Employees WHERE Salary_Rank = 2;
โข Using DENSE_RANK() is useful when multiple employees share the same salary.
๐น 7. Find Products That Never Sold
This is a classic LEFT JOIN problem.
SELECT p.Product_ID, p.Product_Name
FROM Products p
LEFT JOIN Order_Items oi ON p.Product_ID = oi.Product_ID
WHERE oi.Product_ID IS NULL;
Business interpretation: Products exist in the catalog but have no sales.
This could indicate:
โข Poor demand
โข Pricing problems
โข Inventory issues
โข Product visibility problems
๐น 8. Customers With No Orders
The same logic can identify customers who have never purchased.
SELECT c.Customer_ID, c.Customer_Name
FROM Customers c
LEFT JOIN Orders o ON c.Customer_ID = o.Customer_ID
WHERE o.Customer_ID IS NULL;
โค6
โข This can help marketing teams identify potential customers who need activation campaigns.
๐น 9. Customers Above Average Spending
First calculate customer totals. Then compare them with the overall average.
โข Notice how concepts from earlier parts work together: CTE + Aggregation + Subquery
๐น 10. Month-over-Month Sales Growth
First aggregate sales by month. Then use LAG().
โข This produces a time-based comparison instead of just a total.
๐น 11. Calculate Growth Percentage
You can extend the previous query:
โข NULLIF() is important because it prevents division-by-zero errors.
โข A practical analyst must always think about edge cases.
๐น 12. Find the Latest Order for Every Customer
From Part 17, combine PARTITION BY + ORDER BY + ROW_NUMBER()
This is useful for:
โข Customer activity
โข Churn analysis
โข Last purchase reporting
โข CRM segmentation
๐น 13. Identify Potentially Inactive Customers
First find the last purchase date:
Then compare the last order against a chosen inactivity threshold.
โข The business rule might be: No purchase for 90 days โ Potentially inactive
โข The important lesson: SQL provides the calculation. The business defines what "inactive" means.
๐น 14. Find Duplicate Records
Window functions are excellent for detecting duplicates.
โข These records can then be investigated before cleaning the dataset.
๐น 15. Combining Multiple Tables
Real analysis often requires several joins.
For example: Customers โ Orders โ Order_Items โ Products
๐น 9. Customers Above Average Spending
First calculate customer totals. Then compare them with the overall average.
WITH Customer_Sales AS (
SELECT Customer_ID, SUM(Sales) AS Total_Sales FROM Orders GROUP BY Customer_ID
)
SELECT Customer_ID, Total_Sales
FROM Customer_Sales
WHERE Total_Sales > (SELECT AVG(Total_Sales) FROM Customer_Sales);
โข Notice how concepts from earlier parts work together: CTE + Aggregation + Subquery
๐น 10. Month-over-Month Sales Growth
First aggregate sales by month. Then use LAG().
WITH Monthly_Sales AS (
SELECT EXTRACT(YEAR FROM Order_Date) AS Year,
EXTRACT(MONTH FROM Order_Date) AS Month,
SUM(Sales) AS Total_Sales
FROM Orders
GROUP BY EXTRACT(YEAR FROM Order_Date), EXTRACT(MONTH FROM Order_Date)
),
Comparison AS (
SELECT Year, Month, Total_Sales,
LAG(Total_Sales) OVER (ORDER BY Year, Month) AS Previous_Sales
FROM Monthly_Sales
)
SELECT Year, Month, Total_Sales, Previous_Sales, Total_Sales - Previous_Sales AS Sales_Change
FROM Comparison;
โข This produces a time-based comparison instead of just a total.
๐น 11. Calculate Growth Percentage
You can extend the previous query:
(Total_Sales - Previous_Sales) / NULLIF(Previous_Sales, 0) * 100
โข NULLIF() is important because it prevents division-by-zero errors.
โข A practical analyst must always think about edge cases.
๐น 12. Find the Latest Order for Every Customer
From Part 17, combine PARTITION BY + ORDER BY + ROW_NUMBER()
WITH Ranked_Orders AS (
SELECT Customer_ID, Order_ID, Order_Date,
ROW_NUMBER() OVER (PARTITION BY Customer_ID ORDER BY Order_Date DESC) AS rn
FROM Orders
)
SELECT Customer_ID, Order_ID, Order_Date FROM Ranked_Orders WHERE rn = 1;
This is useful for:
โข Customer activity
โข Churn analysis
โข Last purchase reporting
โข CRM segmentation
๐น 13. Identify Potentially Inactive Customers
First find the last purchase date:
SELECT Customer_ID, MAX(Order_Date) AS Last_Order_Date FROM Orders GROUP BY Customer_ID;
Then compare the last order against a chosen inactivity threshold.
โข The business rule might be: No purchase for 90 days โ Potentially inactive
โข The important lesson: SQL provides the calculation. The business defines what "inactive" means.
๐น 14. Find Duplicate Records
Window functions are excellent for detecting duplicates.
WITH Duplicate_Check AS (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY Customer_ID, Order_Date, Sales ORDER BY Order_ID) AS rn
FROM Orders
)
SELECT * FROM Duplicate_Check WHERE rn > 1;
โข These records can then be investigated before cleaning the dataset.
๐น 15. Combining Multiple Tables
Real analysis often requires several joins.
For example: Customers โ Orders โ Order_Items โ Products
SELECT c.Customer_ID, c.Customer_Name, p.Product_Name, oi.Quantity, oi.Sales
FROM Customers c
JOIN Orders o ON c.Customer_ID = o.Customer_ID
JOIN Order_Items oi ON o.Order_ID = oi.Order_ID
JOIN Products p ON oi.Product_ID = p.Product_ID;
โค3