WHERE and HAVING in a SQL in Teradata

You can have both WHERE and HAVING in a SQL.

WHERE - filters before grouping
HAVING - filters after grouping

SELECT id, AVG(salary)
FROM tbl_emp
WHERE id >1000
GROUP BY id HAVING AVG(salary)>10000

In the above code,
Before grouping the WHERE filter condition happens.
So, only ids which are greater than 1000 be the first result set over which GROUP BY clause will act.
After grouping, for each individual group item HAVING clause operation is performed.