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

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…

Contents