What's the difference between HAVING and LIMIT

Hey so I’m looking into SQL and I’m having a hard time understanding HAVING. What is it’s function because all I’m understanding from it is that it just feels like a more complex version of LIMIT.

What are the differences and how can I use HAVING correctly?

The HAVING clause filters groups (WHERE filters rows).

LIMIT does just that, limits the number of items returned from your query.

Ex:

SELECT *
FROM bands
LIMIT 10;

and,

SELECT employee, dept, SUM(salary) AS salary
FROM employees
GROUP BY dept
HAVING SUM(salary) >= 70000 

Order of operations:
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY

2 Likes