Home > Database > Mysql Tutorial > body text

How to write sql sum statement?

不言
Release: 2020-10-12 17:31:16
Original
45792 people have browsed it

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

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

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!

Related labels:
sql
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!