MySQL grouped data

Source: Internet
Author: User
Group understanding grouping can be seen in the following example, first we print out the Products table as follows

As can be seen from the table above, each vendor has a number of products, then how to count how many products per vendor at a time? Here you can use GROUP by, as follows

If you do not use GROUP BY, the result is how many rows are counted:

Packet filter Packet filtering is also a multi-statistic data and then filtered, as the above example, the statistics out of each vendor has a number of products, then you can use having to filter out the number of products more than 3 vendor:


The WHERE statement can drink the having statement together with the spirit and use, if need to find out, there are more than 2 kinds of product price greater than 10:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.