sum函数

简介: sum函数

SUM() 函数
SUM 函数返回数值列的总数(总额)。

SQL SUM() 语法
SELECT SUM(column_name) FROM table_name
SQL SUM() 实例
我们拥有下面这个 "Orders" 表:

O_Id OrderDate OrderPrice Customer
1 2008/12/29 1000 Bush
2 2008/11/23 1600 Carter
3 2008/10/05 700 Bush
4 2008/09/28 300 Bush
5 2008/08/06 2000 Adams
6 2008/07/21 100 Carter
现在,我们希望查找 "OrderPrice" 字段的总数。

我们使用如下 SQL 语句:

SELECT SUM(OrderPrice) AS OrderTotal FROM Orders
结果集类似这样:

OrderTotal
5700

目录
相关文章
|
3月前
|
Serverless
COUNT函数
COUNT函数计算包含数字的单元格以及参数列表中数字的个数。使用函数 COUNT可以获取区域或数字数组中数字输入项的个数。 (1)语法格式:COUNT(valuel,value2,…) (2)功能:计算区域中包含数字的单元格个数
|
机器学习/深度学习
计算sum=1+2...+n,要求number和sum的类型都是int,且sum在32位以内~
计算sum=1+2...+n,要求number和sum的类型都是int,且sum在32位以内~
|
SQL Oracle 关系型数据库
count函数
count函数
163 0
|
文件存储
Sum of Round Numbers
Sum of Round Numbers
145 0
Sum of Round Numbers
HDOJ 1003 Max Sum
HDOJ 1003 Max Sum
108 0
HDOJ1003Max Sum
HDOJ1003Max Sum
90 0
面试题:sum=1+2-3+4-5...+m 公式:sum=2-m/2
sum=1+2-3+4-5...+m 公式:sum=2-m/2
816 0
|
算法 C#
算法题丨3Sum
描述 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
1245 0
|
存储 算法 C#
算法题丨Two Sum
描述 Given an array of integers, return indices of the two numbers such that they add up to a specific target.
1179 0
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
790 0