Intermediate SQL Tutorial | Having Clause

preview_player
Показать описание

In today's Intermediate SQL lesson we walk through the Having Clause. Very underappreciated in the SQL community if you ask me.

All Topics Covered: Joins, Unions, Case Statements, Updating/Deleting Data, Partition By, Data Types, Aliasing, Views, Having Clause, GetDate(), Primary vs Foreign Key

____________________________________________

SUBSCRIBE!
Do you want to become a Data Analyst? That's what this channel is all about! My goal is to help you learn everything you need in order to start your career or even switch your career into Data Analytics. Be sure to subscribe to not miss out on any content!
____________________________________________

RESOURCES:

Coursera Courses:

Udemy Courses:

*Please note I may earn a small commission for any purchase through these links - Thanks for supporting the channel!*
____________________________________________

Websites:

____________________________________________

*All opinions or statements in this video are my own and do not reflect the opinion of the company I work for or have ever worked for*
Рекомендации по теме
Комментарии
Автор

So short, yet so precise. Thank you Alex.

ikharonajohn
Автор

Very helpful and great content. I love the way you make these videos into a series with short playtime so people won't feel overwhelmed by the content. Keep going on Alex, your channel is a wonder!

edricnes
Автор

Recently I'm learning SQL and these videos are really helpful. Thank you Alex!

trudydu
Автор

As I go through the contents. I am amazed and taking all these small steps at its strides. Thank you once again

FrederickFongTW
Автор

Thank you! Your tutorial was very important for me

MaynaraLino
Автор

I love your videos man, they are short and show just what i need

adairyauyo
Автор

Or how my college instructor would say "WHERE can't math" to explain using HAVING for Aggregate functions

jacobmark
Автор

I hope you know that this is great stuff! This is all taught really well, and will definitely help me in my Technical Consultant position. Thank you!

MAP
Автор

Commenting for traction as I continue learning, thanks as always for the videos!

jeremyv
Автор

Alex, you're the real deal. Much love. Posterity willl definitely remember you

Wealth_Focus
Автор

This is a great series, and the examples go over why some SQL does and does not work which is very helpful.

webcomber
Автор

Truly enjoyed this series thus far! Thanks so much Alex!

Orionk
Автор

Wow a YouTube video that just gives you the information you need to the point. What is this 2005?? Thanks!!

WiteBot
Автор

I have bee trying to understand the having statement and I can say that these short series videos do not overwhelm at all. And yes! I now get the having clause.

habibmaryam
Автор

Thanks for the Videos Alex! Really clear and simple explanations! For everyone following along, I think he deleted HR entry from the EmployeeDemographics table. It be really funny if he pops up in the videos moving forward.

LAB-xwco
Автор

Ah I was having trouble with this. Thanks so much for the great explanation and I hope you recover soon!

bru
Автор

very well explained the topic as I have gone through several videos of SQL queries however this video has explained everything in depth, appreciated #Alex The Analyst for your efforts, thanks for these videos

sonalsharma
Автор

Thank you so much Alex, clear and simple explanations!

ahmedcheikhsidiya
Автор

From Chat GPT:
WHERE Clause
Purpose:

The WHERE clause is used to filter rows before any groupings are made. It filters records based on specified conditions.
Usage: Applied to individual rows in a table.
It cannot be used with aggregate functions (like SUM(), COUNT(), AVG(), etc.).
When to Use: Use the WHERE clause to filter records before aggregation or grouping.

Example:
SELECT * FROM Employees
WHERE Salary > 50000;

HAVING Clause
Purpose: The HAVING clause is used to filter groups after the GROUP BY clause has been applied. It filters records based on aggregate conditions.
Usage: Applied to groups of rows created by the GROUP BY clause.
Can be used with aggregate functions.
When to Use: Use the HAVING clause to filter aggregated data or groups of data.

Example:
SELECT DepartmentID, COUNT(*) AS EmployeeCount
FROM Employees
GROUP BY DepartmentID
HAVING COUNT(*) > 10;

Key Differences
Order of Execution:
WHERE: Filters rows before grouping and aggregation.
HAVING: Filters groups after grouping and aggregation.
Scope:
WHERE: Filters individual rows.
HAVING: Filters aggregated data (groups of rows).
Aggregate Functions:
WHERE: Cannot be used with aggregate functions.
HAVING: Can be used with aggregate functions.

Combined Use of WHERE and HAVING
In a single query, both WHERE and HAVING clauses can be used together to filter data at different stages of the query:
Filter rows before aggregation with WHERE.
Filter groups after aggregation with HAVING.

Example:
SELECT DepartmentID, AVG(Salary) AS AvgSalary
FROM Employees
WHERE JobTitle = 'Engineer'
GROUP BY DepartmentID
HAVING AVG(Salary) > 70000;

maragee
Автор

thank you Alex for the great tutorials. in this video i couldn't understand the difference between WHERE and HAVING

bitaazari