Home >Database >Mysql Tutorial >How to write sql sum statement?
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.
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 below
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!