Teradata 简明教程
Teradata - Aggregate Functions
Teradata 支持常见的聚合函数。它们可以与 SELECT 语句一起使用。
Teradata supports common aggregate functions. They can be used with the SELECT statement.
-
COUNT − Counts the rows
-
SUM − Sums up the values of the specified column(s)
-
MAX − Returns the large value of the specified column
-
MIN − Returns the minimum value of the specified column
-
AVG − Returns the average value of the specified column
Example
请考虑以下 Salary 表。
Consider the following Salary Table.
EmployeeNo |
Gross |
Deduction |
NetPay |
101 |
40,000 |
4,000 |
36,000 |
104 |
75,000 |
5,000 |
70,000 |
102 |
80,000 |
6,000 |
74,000 |
105 |
70,000 |
4,000 |
66,000 |
103 |
90,000 |
7,000 |
83,000 |
COUNT
以下示例计算 Salary 表中的记录数。
The following example counts the number of records in the Salary table.
SELECT count(*) from Salary;
Count(*)
-----------
5
MAX
以下示例返回最大员工净薪水值。
The following example returns maximum employee net salary value.
SELECT max(NetPay) from Salary;
Maximum(NetPay)
---------------------
83000
MIN
以下示例从 Salary 表中返回最低员工净薪水值。
The following example returns minimum employee net salary value from the Salary table.
SELECT min(NetPay) from Salary;
Minimum(NetPay)
---------------------
36000