3 SQL queries to Master Data analysis

Manish Sharma · Intermediate ·📊 Data Analytics & Business Intelligence ·7mo ago

Key Takeaways

The video covers three essential SQL queries for data analysis: window functions, common table expressions (CTEs), and advanced joins with filters. These queries enable analysts to gain insights within groups, break down complex analysis into simple layers, and handle real-world projects with multiple tables.

Full Transcript

What if I told you there are only three SQL queries you need to master to analyze any data set like a pro. Let's start with the first one. Window functions. Think of them as a secret weapon for analyst who want insights within groups. For example, highest paid employee in each department. Here's how it looks. For every department, we are ranking employees based on salary. But let me break that down a bit more so it's crystal clear. When you write partition by department, you are basically telling SQL to treat each department like a separate mini table. HR becomes its own group. Finance becomes its own group and so on. Inside each group, SQL applies order by salary descending. That means it sorts the employees by salary from highest to lowest within that department. Now rank kicks in. It assigns rank one to the highest salary inside that group, rank two to the next and so on. If two people have the same salary, they both get the same rank. So if HR has 10 people, it gives rank one to the highest paid person in HR, not in the whole company. This one line is doing all this grouping, sorting and ranking at the same time. And if you want to go deeper into window functions and actually master them with real world examples, I have written a book called Mastering SQL Window Functions. I kept it practical, beginner friendly and focused on the exact problem analysts face every day. If you're serious about leveling up your analysis skills, this book will save you months of trial and error. Now, the second query every analyst should know, the CTE or common table expression. It helps you break complex analysis into simple layers. Imagine you want to compare each employees salary with their department's average. Here is how we do it. In the first step, we find the average salary per department. But here is what that really means. The CTE DP average runs first. It groups the data by department ID and calculates one number per group, the department's average salary. So if you have five departments, you end up with five rows. Then in the main query, we join the result back to the employees table. Now every employee gets matched with their department's average salary. Once that link is made, the comparison becomes simple. Check if the employee salary is above or below the average for their own department. This is how real analyst think. Break the logic, reuse the result and keep the query readable. And if you want a deeper breakdown of how CDs work, I have already made a full video on it where I explain it with simple visuals. I will leave the link on the screen and in the description. Watch it whenever you want to master CDEs properly. Finally, the third query advanced joins with filters. Because in real world projects, your data is rarely in one table. Let's say you want to find customers who spent more than 50,000 in the last 3 months. We are joining two tables filtering orders from the last 3 months right inside the on clause and then using having to keep only high value customers. But here is what actually happening behind the scenes. The join connects each customer with their orders and this condition makes sure we only pick recent orders. Everything older than 3 month is ignored before the aggregation even happens. Then SQL groups the data by customer and calculates the total sales for each person. Finally, the having clause filters out anyone whose total doesn't cross 50,000. So you are cleaning the data, matching it, and summarizing it in one clean query. So if you master these three window functions, CDs and smart joys, you can handle almost any SQL analytics problem thrown at you. If you want me to make a part two where I show you how to combine all three in one powerful query, comment part two below. And don't forget to follow for more SQL insights like this. And if you want to learn SQL with me directly, my live training batch is starting soon. Seats are limited. So I'm keeping the enrollment link in the description. Fill it out and if you get selected, my team will reach out to you. Thanks for watching. This is Manish from rebellionrider.com.

Original Description

Unlock the SQL skills you need for 2026 and stay ahead in data analysis! In this video, I reveal the SQL queries that top analysts use every day—perfect for mastering SQL interview questions and real-world reporting. 👉 Grab my book Mastering SQL Window Functions here: https://dataprofy.com/product-category/ebook/ You’ll learn: How window functions help you find top performers per group. How CTEs simplify complex comparisons for clean, readable queries. How advanced joins with filters save time and give accurate insights. If you want to crack SQL interview questions or level up your data analysis in 2026, this video is your roadmap. I’ll break everything down step by step with practical examples so you can apply it immediately. 💡 Bonus: I also share my book Mastering SQL Window Functions for a deeper dive into real-world examples analysts use every day. Don’t forget to comment “Part 2” if you want me to show how to combine all three queries in one powerful analysis. 🚀 Follow me for more SQL tips, tricks, and tutorials that make you interview-ready and future-proof your data analysis skills in 2026. ------------------------------------------------------------------------ ►►►LINKS◄◄◄ ►►►Camera Gears https://www.amazon.in/shop/manishsharma?listId=DU9UM0XL97KM&ref=idea_share_inf ►►► Work From Home Essential Tech That We Use Daily https://www.amazon.in/shop/manishsharma?listId=XAZ18JLLSNB5&ref=idea_share_inf ============================= ============================= Subscribe now for more database tutorials ============================= @RebellionRider ============================= ►►►Connect With Us ============================= https://www.instagram.com/RebellionRider/ https://www.facebook.com/TheRebellionRider/ https://twitter.com/RebellionRider https://www.linkedin.com/in/mannbhardwaj/ ============================= ►►►Books I refer to ============================= PL/SQL https://amzn.to/2QE1jX0 Performance Tuning https
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Manish Sharma · Manish Sharma · 0 of 60

← Previous Next →
1 Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Oracle Database tutorials 1: How to install Oracle Database 11g on windows 7
Manish Sharma
2 Oracle Database tutorials 2:How To install SQL Developer on windows 7
Oracle Database tutorials 2:How To install SQL Developer on windows 7
Manish Sharma
3 Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Oracle Database tutorials 3:How to enable Line numbers in SQL Developer.
Manish Sharma
4 Oracle Database tutorials 4:  database connectivity using SQL developer and command prompt
Oracle Database tutorials 4: database connectivity using SQL developer and command prompt
Manish Sharma
5 Oracle Database tutorials 5:  how to Fetch Data using SELECT - SQL statement by Manish Sharma
Oracle Database tutorials 5: how to Fetch Data using SELECT - SQL statement by Manish Sharma
Manish Sharma
6 Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Oracle Database11g tutorials 6 | | How to use Concatenation operator, character String
Manish Sharma
7 Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Oracle Database11g tutorials 7 | |SQL DISTINCT keyword || SQL tutorials
Manish Sharma
8 Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Canon EOS 600D 2 lens kit/Canon rebell EOS T3i 2 lens kit Unboxing
Manish Sharma
9 First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE  - ORACLE DATABASE ADMINISTRATOR
First look: ORACLE CERTIFIED ASSOCIATE (OCA) CERTIFICATE - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
10 Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Oracle Database11g tutorials 8 || SQL DISTINCT with multiple columns |SQL Distinct with Two columns
Manish Sharma
11 Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Oracle Database11g tutorials 9 || What is archive log mode and how to enable archive log mode
Manish Sharma
12 Oracle Database11g tutorials 10 ||  SQL Single Row Function (SQL Functions )
Oracle Database11g tutorials 10 || SQL Single Row Function (SQL Functions )
Manish Sharma
13 Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Oracle Database11g tutorials 11: SQL case manipulation function in Oracle Database
Manish Sharma
14 how to add channel trailer and section on your youtube channel 2014
how to add channel trailer and section on your youtube channel 2014
Manish Sharma
15 Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Oracle Database11g tutorials 12 || SQL Concat Function - SQL character manipulation function
Manish Sharma
16 Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Oracle Database11g tutorials 13 || SQL substr function / SQL substring function
Manish Sharma
17 Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Oracle Database11g tutorials 14 : How to CREATE TABLE using sql developer and command prompt
Manish Sharma
18 SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
SQL tutorials 15 || How To CREATE TABLE using enterprise manager 11g
Manish Sharma
19 Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Oracle Database11g tutorials 16: How to uninstall oracle 11g from windows 7 64 bit
Manish Sharma
20 ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look  - ORACLE DATABASE ADMINISTRATOR
ORACLE CERTIFIED PROFESSIONAL(OCP) CERTIFICATE First look - ORACLE DATABASE ADMINISTRATOR
Manish Sharma
21 Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Plantronics audio 655 USB headset with Mic Unboxing and Review and Plantronics audio 655 Mic test
Manish Sharma
22 SQL tutorials 17: SQL Primary Key constraint,  Drop primary Key
SQL tutorials 17: SQL Primary Key constraint, Drop primary Key
Manish Sharma
23 SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
SQL tutorials 18: SQL Foreign Key Constraint By Manish Sharma
Manish Sharma
24 SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
SQL tutorial 19: ON DELETE SET NULL clause of Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
25 SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
SQL tutorials 20: On Delete Cascade Foreign Key By Manish Sharma (RebellionRider)
Manish Sharma
26 SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
SQL tutorial 21: How To Rename Table in SQL using ALTER TABLE statement By Manish Sharma
Manish Sharma
27 SQL tutorial 22: How to Add / Delete column from an existing table using alter table
SQL tutorial 22: How to Add / Delete column from an existing table using alter table
Manish Sharma
28 SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
SQL tutorial 23: Rename and Modify Column Using Alter Table By Manish Sharma (RebellionRider)
Manish Sharma
29 SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
SQL tutorial 24 :SQLJoins- Natural Join With ON and USING clause By Manish/Rebellionrider
Manish Sharma
30 Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Oracle Database11g tutorials 25: How to install Oracle Database 11g Express Edition R2 on Windows 7
Manish Sharma
31 SQL tutorial 26: Introduction to SQL Joins in Oracle Database
SQL tutorial 26: Introduction to SQL Joins in Oracle Database
Manish Sharma
32 Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Vidcon 2014 YouTube Fan Funding: How to enable fan funding on YouTube Channel
Manish Sharma
33 SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
SQL tutorial 27: Right Outer Join in SQL by Manish Sharma for RebellionRider
Manish Sharma
34 SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
SQL tutorial 28: Left Outer Join By Manish Sharma / RebellionRider
Manish Sharma
35 SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
SQL tutorial 29: Full Outer Join with example By Manish Sharma/ RebellionRider
Manish Sharma
36 SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
SQL tutorial 30: Inner Join In SQL by Manish Sharma/RebellionRider
Manish Sharma
37 SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
SQL tutorial 31 : SQL Cross Join In Oracle Database By Manish Sharma from RebellionRider
Manish Sharma
38 SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
SQL tutorial 32: How To Insert Data into a Table Using SQL Developer
Manish Sharma
39 SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
SQL tutorial 33:How To Insert Data into a Table Using SQL INSERT INTO dml statement
Manish Sharma
40 SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
SQL tutorial 34: How to copy /Insert data into a table from another table using INSERT INTO SELECT
Manish Sharma
41 SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
SQL tutorial 35: DELETE and TRUNCATE how to delete data from a table
Manish Sharma
42 SQL tutorial 36: how to create database using database configuration assistant DBCA
SQL tutorial 36: how to create database using database configuration assistant DBCA
Manish Sharma
43 SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
SQL tutorial 37: How to create NEW USER account using Create User statement in Oracle database
Manish Sharma
44 SQL tutorial 38: How to create user using SQL Developer in Oracle database
SQL tutorial 38: How to create user using SQL Developer in Oracle database
Manish Sharma
45 SQL tutorial 39: How to create user in oracle using Enterprise Manager
SQL tutorial 39: How to create user in oracle using Enterprise Manager
Manish Sharma
46 SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
SQL tutorial 40: DBA Trick, How to drop a user when it is connected to the database
Manish Sharma
47 Motorola Moto G 2nd Generation / G2 Unboxing and Review
Motorola Moto G 2nd Generation / G2 Unboxing and Review
Manish Sharma
48 SQL tutorial 41: How to UNLOCK USER in oracle Database
SQL tutorial 41: How to UNLOCK USER in oracle Database
Manish Sharma
49 SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
SQL tutorial 42: How to Unlock user using SQL Developer By Manish Sharma RebellionRider
Manish Sharma
50 SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
SQL tutorial 43: How to create an EXTERNAL USER in oracle database By Manish Sharma RebellionRider
Manish Sharma
51 SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
SQL tutorial 44: How to import data from Microsoft Excel to Oracle Database using SQL Developer
Manish Sharma
52 SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
SQL tutorial 45: Introduction to user Privileges in Oracle Database By Manish Sharma RebellionRider
Manish Sharma
53 SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
SQL tutorial 46: What are System Privileges & How To Grant them using Data Control Language
Manish Sharma
54 SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
SQL tutorial 47: How to Grant Object Privileges With Grant Option in Oracle Database
Manish Sharma
55 SQL tutorial 48: How to create Roles in Oracle Database
SQL tutorial 48: How to create Roles in Oracle Database
Manish Sharma
56 SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
SQL tutorial 49: CASE - Simple Case Expression in Oracle Database (1/2)
Manish Sharma
57 SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
SQL tutorial 50: CASE - Searched Case Expression In Oracle (2/2)
Manish Sharma
58 SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
SQL tutorial 51: DECODE function in Oracle Database By Manish Sharma (RebellionRider)
Manish Sharma
59 Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Oracle Database Tutorial 52 : Data Pump expdp - How to Export full database using expdp
Manish Sharma
60 Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Oracle Database Tutorial 53 : Data pump expdp - How to Export tablespace in Oracle Database
Manish Sharma

Master three essential SQL queries to analyze any data set like a pro. Window functions help with insights within groups, CTEs break down complex analysis, and advanced joins handle real-world projects. With these queries, you can handle almost any SQL analytics problem.

Key Takeaways
  1. Use window functions to rank employees by salary within each department
  2. Apply CTEs to compare each employee's salary with their department's average
  3. Utilize advanced joins with filters to find customers who spent more than 50,000 in the last 3 months
💡 Mastering these three SQL queries enables analysts to handle almost any SQL analytics problem and gain valuable insights from their data.

Related Reads

📰
The Invisible Architecture of Truth: Why the World’s Most Boring System is Our Last Defense Against…
Discover how Universal Bibliographic Control, a fundamental concept in library science, plays a crucial role in maintaining truth and accuracy in our increasingly complex world
Medium · AI
📰
The Invisible Architecture of Truth: Why the World’s Most Boring System is Our Last Defense Against…
Learn about Universal Bibliographic Control and its importance in maintaining data integrity and truth
Medium · Data Science
📰
What If Fraud Doesn’t Live in Transactions? What If It Lives Between Them?
Learn to detect financial fraud by analyzing relationships between transactions, not just individual transactions
Medium · Data Science
📰
5 SQL Interview Questions That Trip Up Beginners
Learn to tackle common SQL interview questions that trip up beginners and improve your chances of acing a tech interview
Dev.to · Juhi Singhal
Up next
How AI, MCP & Tableau Extensions Are Transforming Analytics
Salesforce Product Center
Watch →