In mysql, there are two functions: count () and sum (). Many of them are confused. From an English perspective, we can find that count is the number of statistics, sum is the sum of values and can only be numeric.
In mysql, there are two functions:
Count () differs from sum () in MySQLFirst, create a table to illustrate the problem create table ' result ' (' name ' varchar () default NULL, ' subject ' varchar () default NULL, ' Score ' tinyint ( 4) Default NULL) Engine=myisam default
MySQL learning footprint record 10 -- Summary Data -- data used in this article, such as MAX (), MIN (), AVG (), SUM (), and COUNT ()
mysql> SELECT prod_price FROM products;+------------+| prod_price |+------------+| 5.99 || 9.99 ||
Title MySQL SUM () COUNT () is also in the work of the recordSUM () returns the number of columns and the total number of points such as a studentEg:select sum (obj) from table is definitely the sum of the numbers of the obj columns in the table
Requirements: Check out the average score of 2 and 2 people who fail.There are two types of query statements that are often used:
The code is as follows
Copy Code
1. Select Name,sum (Score =2;
Look again
Count
Difference between count () and sum () in Mysql bitsCN.com
First, create a table to describe the problem.
Create table 'result '(
'Name' varchar (20) default NULL,
'Subobject' varchar (20) default NULL,
'Score 'tinyint (4) default NULL
) ENGINE =
After the avg (), count (), min () max (), sum () functions of mysql are familiar with the simplest SQL statements, do you think the cmd form is particularly appealing to tao Huan (yan )!
Of course, we have a more intuitive and easy way to use
MySQL learning footprint record 10 -- Summary Data -- MAX (), MIN (), AVG (), SUM (), COUNT () bitsCN.com
MySQL learning footprint record 10 -- Summary Data -- MAX (), MIN (), AVG (), SUM (), COUNT ()
Data used in this article
mysql> SELECT prod_
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.