Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

HAVING
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

HAVING

In MySQL, the HAVING clause is used in conjunction with the GROUP BY clause to filter the results of a query based on aggregate functions.

The HAVING clause is applied after the GROUP BY clause and allows you to specify conditions for groups of rows. It is primarily used with aggregate functions like SUM, COUNT, AVG, etc.

Syntax

SELECT column_name FROM table_name WHERE condition GROUP BY column_name HAVING condition

Example

Suppose we have a Students table as shown below:

Now, let's say you want to find courses where the number of students who

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible