In mysql, you can use the sum() function to sum fields. The function of this function is to return the total number of numerical columns. The syntax is "SELECT sum (evaluated field) FROM 'table name'".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How does mysql sum fields
In mysql, if you want to sum fields, you need to use the sum function.
The SUM() function returns the total number of numeric columns.
The syntax is as follows:
SELECT SUM(column_name) FROM table_name;
The example is as follows:
mysql> select SUM(price) from order where create_time>'2016-03-12'; +------------+ | SUM(price) | +------------+ | 37.40 | +------------+ 1 row in set
The above is the detailed content of How to sum fields in mysql. For more information, please follow other related articles on the PHP Chinese website!