CodePudding user response:
What you see is having behind...CodePudding user response:
Behind the where noThe where...
Group by... Having...
CodePudding user response:
why sometimes see using aggregate functions, please comment, thank youSee from?
References 1, 2 floor of reply,
CodePudding user response:
Aggregation function with five commonly used in mysql:1, the count (); Count
2, the Max (); The maximum
3, min (); The minimum
4, the sum (); Sum
5, avg (); Averaging
Where not directly behind the made filter conditions aggregation function, if the aggregate function is used as the filter conditions, can only be used after having, if appear, the subquery should be behind the where to meet?
CodePudding user response:
By having, or write a subquery, for example:SELECT * FROM (SELECT ID, COUNT (0) C FROM TABLE_NAME GROUP BY ID) T WHERE tc & gt;=0;
CodePudding user response:
You should see is the subquery in the count,The where (select count (1) the from XXX) & gt;=N?
If not, see 3 floor, I also want to see,