Home >Database >Mysql Tutorial >How to write sql sum statement?

How to write sql sum statement?

不言
不言Original
2019-03-02 17:37:5645980browse

There is a summation function in the SQL statement that can be used to sum. This function is the sum function, which is used to return the total number of numerical columns. Let's take a look at the specific usage of the sum function in SQL.

How to write sql sum statement?

First let’s take a look at the syntax of the sum function

SELECT SUM(column_name) FROM table_name

Let’s take a look at a specific example

Let’s look at the table belowHow to write sql sum statement?

Now we need to add and sum the numbers in the OrderPrice column

The SQL statement is as follows

SELECT SUM(OrderPrice) AS OrderTotal FROM Orders

The result is: 5700

The above is the detailed content of How to write sql 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