1,group by creating a group
In MySQL group by sentence to note that must after where the order by
Select Order_code, COUNT (*) as product from order group by Order_code;
2,having Packet filtering
The WHERE clause can be replaced by the having, the difference is where the filter row, having a filter group; having all the where operators supported
However, where cannot be used to replace the having group filter
Select Order_code, COUNT (*) as product from order GROUP by Order_code have Count (*) >2;
The difference between having and where:
Where the data is grouped before filtering, having the data is grouped after filtering; where excluded rows are not included in the grouping (this may change the calculated value, thereby affecting the grouping that is filtered out of the HAVING clause based on those values)
MySQL GROUP by group and having filter grouping