You just need to remember that the relationship between having and group by is just like the relationship between where and select. Since you can write various conditions in where, you can also write in having. However, since it is already group by, it is generally used in having. For aggregate functions, like your SQL, mentioning the condition name<2 of having in front and writing it in where is the same as the result of this sentence, so it makes no sense to write this condition in having.
having
后面跟一个条件表达式,name<2
合理呀,单纯一个name
That’s called an expression.You just need to remember that the relationship between having and group by is just like the relationship between where and select. Since you can write various conditions in where, you can also write in having. However, since it is already group by, it is generally used in having. For aggregate functions, like your SQL, mentioning the condition name<2 of having in front and writing it in where is the same as the result of this sentence, so it makes no sense to write this condition in having.