Home  >  Article  >  Database  >  What is the mysql sum statement?

What is the mysql sum statement?

藏色散人
藏色散人Original
2021-12-02 11:49:244572browse

MySQL summation statement is "select sum(money) from record t where t.name = ?", where the parameter t represents the alias of a table.

What is the mysql sum statement?

The operating environment of this article: Windows 7 system, Mysql version 5.7.14, Dell G3 computer.

What is the mysql sum statement?

Example: Query the added value of money with name=? in the record table

Use polysum Function sum() summing

select sum(money) from record t where t.name = ?

Note: t is an alias of a table. For example, t.name is the name in the record table. You can also use record.name, but it is too long, so use a Aliases are more convenient

Extended information:

Aggregation functions are AVG, COUNT, MAX, MIN and SUM. The syntax of aggregate functions is described in the following example

aggregation-function ( [ ALL | DISTINCT ] expression )

or: COUNT( [ ALL | DISTINCT ] identification-variable )

or: COUNT( * )

Before applying the function, DISTINCT Option to eliminate duplicate values.

[Related recommendations: mysql video tutorial]

The above is the detailed content of What is the mysql sum statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn