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

目录
相关文章
|
1月前
|
编译器 C++
C++ max函数与min函数
C++ max函数与min函数
|
6月前
|
机器学习/深度学习
计算sum=1+2...+n,要求number和sum的类型都是int,且sum在32位以内~
计算sum=1+2...+n,要求number和sum的类型都是int,且sum在32位以内~
|
SQL Oracle 关系型数据库
count函数
count函数
94 0
|
文件存储
Sum of Round Numbers
Sum of Round Numbers
82 0
Sum of Round Numbers
面试题:sum=1+2-3+4-5...+m 公式:sum=2-m/2
sum=1+2-3+4-5...+m 公式:sum=2-m/2
776 0
|
人工智能 C++
c++直接用count直接调用函数
今天下午一个同学问我为什么他的交集会出现这个情况,就是多出来个3 1 #include 2 #define M 1000 3 using namespace std; 4 int jiaoji(int a[M],int b[M],int n) 5 { 6 int i,j,k=0,c[M...
1009 0
|
存储 算法 C#
算法题丨Two Sum
描述 Given an array of integers, return indices of the two numbers such that they add up to a specific target.
1134 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.
1200 0
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
767 0