Differences between where and having:
The where clause cannot contain clustering functions, because it is meaningless to try to use clustering functions to judge the input rows to clustering operations. Conversely, having clauses always contain aggregate functions.
Having generally follows group by and executes part of the selected record group to work.
Where is used to execute all data. In addition, having can be used as an aggregate function, such as having sum (qty)> 1000.
1. Use different places
Where can be used in select, update, delete, and insert... into statements.
Having can only be used in select statements.
2. The execution sequence is different.
The where search condition is applied before the statement is executed for grouping.
Having search conditions are executed after grouping conditions.
That is, if where and having are used together, where will be executed first, having will be executed later.
3. clauses are different
The conditional expression having in the WHERE clause can be followed, while some expressions in the having clause cannot be followed. The having clause can use a set function (sum, Count, AVG, Max, and min ), the where clause is not allowed.
4. Different objects
The where clause acts on tables and views, and the having clause acts on groups.