MySQL's Count,max,min,sum,avg,celing,floor

Source: Internet
Author: User
Tags floor function mathematical functions mysql create mysql create database

Write in front

Yesterday went to Tsing Lung Gorge to play a day, tired and dog-like. But fortunately, finally counted on the top of the mountain, but also count to Beijing after the conquest of the third mountain. Here also nagging, do the development of this line, nothing or more sports, on their own or very good, nonsense less, or toss toss the SQL statement it.

Series Articles

MySQL CREATE database, create data table

MySQL's select,insert,delete,update

MySQL group By,order by

Count

Count, often used in conjunction with the group BY statement, at this point, you can understand the number of groupings after grouping. Also take the previous data sheet tb_student as an example.

1. Calculate the number of students enrolled on the same day.

 Use School; -- calculate the number of students enrolled on the same day.  SelectCount(1 as 'countas fromGroup   by date (createdate);

MAX

1, the largest ID

1  Use School; 2 Select Max  from Tb_student;

Min

1. Minimum ID

 Use School; Select min  from Tb_student;

SUM

1. Find out the age of all students and

 Use School; Select sum  from Tb_student;
Avg

1. Average age of all students

 Use School; Select avg  from Tb_student;

Celing

Celing translation comes from the meaning of "ceiling", meaning, regardless of what is behind the decimal point, go upward. Like the upper age average.

 Use School; Select Ceiling (avg(age))   from Tb_student;

Of course, and the ceiling corresponding to the floor function, of course, it means the opposite.

Floor
 Use School; Select  Floor (avg(age))   from Tb_student;

Summarize

Here is a summary of some of the common mathematical functions, which are often used when doing statistics.

MySQL's Count,max,min,sum,avg,celing,floor

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.