MySQL queries the total number of records after using GROUP by

Source: Internet
Author: User

Test table

To find out what a user is doing, combine the actions

The following SQL can be used to achieve the purpose

SELECT  as Operation  from Test GROUP  by NAME

Then to find out how many such users, directly after the Select plus the count () function has no effect.

One solution is to use the query result as a table, with select COUNT (*) in the outer layer

SELECT COUNT (*from(SELECT as operation from test GROUP  by   as T

Another easier way is to use the DISTINCT keyword

SELECT COUNT (DISTINCT from test

MySQL queries the total number of records after using GROUP by

Related Article

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.