【译文】如何在ACCESS SQL中使用聚合函数
时 间:2014-03-24 09:17:38
作 者:周芳 ID:24526 城市:上海
摘 要: 聚合函数用于计算统计和汇总信息表中的数据。在SELECT语句中使用这些函数,所有字段或表达式都可以作为参数。
正 文:
来自:微软 翻译:周芳
【译文】如何在ACCESS SQL中使用聚合函数
聚合函数用于计算统计和汇总信息表中的数据。在Select语句中使用这些函数,所有字段或表达式都可以作为参数。
计算一个结果集记录的数量,使用计数函数。在计数函数中使用星号使空值也可以同样计算。
VBA
Select Count(*) AS [Number of Invoices]
FROM tblInvoices
计算非空值时,在计数函数中使用一个字段名
VBA
Select Count(Amount) AS
[Number of Valid Invoice Amounts]
FROM tblInvoices
要找出数据中一列的平均值,使用Avg函数
VBA
Select Avg(Amount) AS [Average Invoice Amount]
FROM tblInvoices
要找出数据中一列的总数,使用Sum函数
VBA
Select Sum(Amount) AS [Total Invoice Amount]
FROM tblInvoices
要找出一列中的最小值,使用Min函数
VBA
Select Min(Amount) AS [Minimum Invoice Amount]
FROM tblInvoices
要找出一列中的最大值,使用Max函数
VBA
Select Max(Amount) AS [Maximum Invoice Amount]
FROM tblInvoices
要找出一列中第一个值,使用First函数
VBA
Select First(Amount) AS [First Invoice Amount]
FROM tblInvoices
要找出一列中最后一个值,使用Last函数
VBA
Select Last(Amount) AS [Last Invoice Amount]
FROM tblInvoices
【原文】How to: Use Aggregate Functions to Work with Values in Access SQL
Aggregate functions are used to calculate statistical and summary information from data in tables. These functions are used in Select statements, and all of them take fields or expressions as arguments.
To count the number of records in a result set, use the Count function. Using an asterisk with the Count function causes Null values to be counted as well.
VBA
Select Count(*) AS [Number of Invoices]
FROM tblInvoices
To count only non-Null values, use the Count function with a field name.
VBA
Select Count(Amount) AS
[Number of Valid Invoice Amounts]
FROM tblInvoices
To find the average value for a column or expression of numeric data, use the Avg function.
VBA
Select Avg(Amount) AS [Average Invoice Amount]
FROM tblInvoices
To find the total of the values in a column or expression of numeric data, use the Sum function.
VBA
Select Sum(Amount) AS [Total Invoice Amount]
FROM tblInvoices
To find the minimum value for a column or expression, use the Min function.
VBA
Select Min(Amount) AS [Minimum Invoice Amount]
FROM tblInvoices
To find the maximum value for a column or expression, use the Max function.
VBA
Select Max(Amount) AS [Maximum Invoice Amount]
FROM tblInvoices
To find the first value in a column or expression, use the First function.
VBA
Select First(Amount) AS [First Invoice Amount]
FROM tblInvoices
To find the last value in a column or expression, use the Last function.
VBA
Select Last(Amount) AS [Last Invoice Amount]
FROM tblInvoices
Access软件网官方交流QQ群 (群号:483923997) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access窗体导出PDF】...(04.08)
- 【Access窗体导出PDF】...(04.07)
- Access两种方式实现即时更...(03.01)
- Access隐藏与显示lacc...(01.12)
- 【Access高效办公】将每个...(12.23)
- Access21点游戏源代码(12.13)
- 【Access窗体导出Exce...(11.15)
- 【Access开发】Acces...(11.14)
- 通过Access宏录入数据到选...(11.10)
学习心得
最新文章
- Access学习笔记--用Acce...(04.19)
- 【Access重复项查询示例】将A...(04.17)
- Access快速开发平台企业版--...(04.16)
- 【Access模块示例】通过模块代...(04.15)
- Access查询里面分组合计功能添...(04.13)
- 【Access删除查询】删除数字最...(04.12)
- 显示文件夹中所有文件的修改时间(04.11)
- 铁路工程管理系统;铁路工程管理小程...(04.10)
- 【Access查询示例】怎么将两个...(04.09)
- 【Access窗体导出PDF】Ac...(04.08)