Think about what you need to do if you wish to implement:
- WHERE: Its need to execute the JOIN operations.
- GROUP BY: You specify Group by to "group" the results on the join, then it has to after the JOIN operation, after the WHERE usage.
- HAVING: HAVING is for filtering as GROUP BY expressions says. Then, it is executed after the GROUP BY.
The order is WHERE, GROUP BY and HAVING.