group by + polymerizable function formula:
max maximum value;
minimum min;
avg average;
sum sum;
calculated count the number of columns;
Specific examples:
select count (*) from table name; # lists the number of columns in the table
select count (user) from table name; # lists the number of columns in the table user columns
# Here to find out where you can use with
select count (id) from table where name = root; how many names there are for the statistics # id root of
# But I feel this count function used much, but behind like max, min, sum used more
Mysql below comes with a user database
select user, count(host) from mysql.user;
select user, count (user) from group by user; #t user statistics and calculate the number of how many users
Like the above-mentioned sum function as long as the replacement count function on the line #, but the need for sums required for the job.
order by sorting the data output
select user, count (host) from mysql.user group by user order by host; host # number of statistics in the user table and sorted in ascending sort order by default, may join desc parameter in descending order;
limit parameters, and the general application scenario with order by using the number of lines from the definition of the role of access to data;
select user, count (host) from mysql.user group by user order by host limit 5; front-line # 5 to the parameters