HAVING is used when you have a GROUP BY clause and you are trying to filter based on one of the grouping fields; WHERE is used for filtering otherwise.
eg.
select StudentName from students where Age > 20
select className, count(studentId) from classes group by className
having count(studentId) > 10