From the course: MySQL Data Analysis
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
The HAVING clause - MySQL Tutorial
From the course: MySQL Data Analysis
The HAVING clause
- [Instructor] All right, now we're ready to talk about the fifth of the big six, the HAVING clause. HAVING is where you specify group-level filtering criteria. Previously, we've used WHERE conditions to filter individual records. HAVING works very similarly, but instead of acting on individual records, it's going to act on groups. The syntax looks like this, HAVING followed by some logical condition, and this is where you specify exactly what you want to use to filter your group-level aggregated metrics. Some examples of things you might do, HAVING COUNT star greater than one. So, that would only show groups that had a count of records which was greater than one. You could do HAVING SUM of payment is greater than 10, so that would only show groups whose total cumulative payments were over 10, or you could do HAVING MIN rental date less than 2005, May 25th, and that would only pull in groups who had a minimum rental date before that day. This is really important to remember. You can…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Introduction24s
-
(Locked)
Getting to know the database3m 52s
-
(Locked)
The Big 62m 18s
-
(Locked)
The SELECT statement47s
-
(Locked)
The FROM clause39s
-
SELECT * FROM6m
-
(Locked)
The USE statement3m 19s
-
(Locked)
Selecting specific columns4m 18s
-
(Locked)
Challenge: SELECT and FROM1m 24s
-
(Locked)
Solution: SELECT and FROM2m 38s
-
(Locked)
SELECT DISTINCT2m 13s
-
(Locked)
Challenge: SELECT DISTINCT38s
-
(Locked)
Solution: SELECT DISTINCT2m
-
(Locked)
The WHERE clause1m 30s
-
(Locked)
Common WHERE operators4m 59s
-
(Locked)
Challenge: The WHERE clause35s
-
(Locked)
Solution: The WHERE clause2m 23s
-
(Locked)
Combining WHERE and AND4m 22s
-
(Locked)
Challenge: WHERE and AND39s
-
(Locked)
Solution: WHERE and AND1m 37s
-
(Locked)
Combining WHERE and OR3m 38s
-
(Locked)
Challenge: Combining WHERE and OR42s
-
(Locked)
Solution: Combining WHERE and OR3m 21s
-
(Locked)
Combining WHERE and IN4m 35s
-
(Locked)
The LIKE operator2m 37s
-
LIKE wildcard examples5m 6s
-
(Locked)
Challenge: The LIKE operator30s
-
(Locked)
Solution: The LIKE operator2m 28s
-
(Locked)
The GROUP BY clause1m 43s
-
(Locked)
GROUP BY example3m 18s
-
(Locked)
Pro Tip: Using comments and aliases5m 32s
-
(Locked)
Challenge: GROUP BY37s
-
(Locked)
Solution: GROUP BY2m 1s
-
(Locked)
Multiple dimension GROUP BY clauses3m 14s
-
(Locked)
Aggregate functions2m 8s
-
(Locked)
Challenge: Aggregate functions55s
-
(Locked)
Solution: Aggregate functions3m 23s
-
(Locked)
The HAVING clause1m 44s
-
(Locked)
HAVING example2m 54s
-
(Locked)
Challenge: The HAVING clause54s
-
(Locked)
Solution: The HAVING clause3m 11s
-
(Locked)
The ORDER BY clause1m 31s
-
(Locked)
ORDER BY example4m 16s
-
(Locked)
Challenge: The ORDER BY clause30s
-
(Locked)
Solution: The ORDER BY clause1m 47s
-
(Locked)
Recap: The Big 62m 8s
-
(Locked)
-
-
-
-