Home > Database > Mysql Tutorial > body text

What is the mysql sum statement?

藏色散人
Release: 2021-12-02 11:49:24
Original
4578 people have browsed it

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 = ?
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template