Funções agregadas permitem obter informação estatística
sobre um conjunto de registros
Por exemplo, pode usar uma função
agregado para contar o número de registros em um conjunto particular de
registros, ou determinar a média de valores em um campo
particular.
Objectivo | Função | Exemplo |
Calcular a média de um conjunto de valores de uma tabela |
DAvg Function |
|
Contar o número de registos |
DCount Function |
![]() |
Procurar um valor |
DLookup Function |
![]() |
DFirst, DLast Functions |
||
Calcular o mínimo e máximo de um valor |
DMin, DMax Functions |
![]() |
Funções estatísticas |
DStDev, DStDevP Functions |
|
Calcular somatórios |
DSum Function |
|
Funções estatísticas |
DVar, DVarP Functions |
You can use the DAvg function to calculate the average of a set of values in a specified set of records (a domain
). Use the DAvg function in Visual Basic code or in a macro, in a query expression, or in a calculated control.
For example, you could use the DAvg function in the criteria row of a select query on freight cost to restrict the results to those records where the freight cost exceeds the average. Or you could use an expression including the DAvg function in a calculated control, and display the average value of previous orders next to the value of a new order.
Syntax
DAvg(expr, domain[, criteria])
Ex:
Dim dblX As Double, strCountry As String
strCountry = "UK"
dblX = DAvg("[Freight]", "Orders", "[ShipCountry] = '" & strCountry & "'")
You can use the DCount function to determine the number of records that are in a specified set of records (a domain). Use the DCount function in Visual Basic, a macro, a query expression, or a calculated control.
For example, you could use the DCount function in a module to return the number of records in an Orders table that correspond to orders placed on a particular date.
Syntax
DCount(expr, domain[, criteria])
You can use the DLookup function to get the value of a particular field from a specified set of records (a domain). Use the DLookup function in Visual Basic, a macro, a query expression, or a calculated control on a form or report.
You can use the DLookup function to display the value of a field that isn't in the record source for your form or report. For example, suppose you have a form based on an Order Details table. The form displays the OrderID, ProductID, UnitPrice, Quantity, and Discount fields. However, the ProductName field is in another table, the Products table. You could use the DLookup function in a calculated control to display the ProductName on the same form.
Syntax
DLookup(expr, domain[, criteria])
You can use the DMin and DMax functions to determine the minimum and maximum values in a specified set of records (a domain). Use the DMin and DMax functions in Visual Basic, a macro, a query expression, or a calculated control.
For example, you could use the DMin and DMax functions in calculated controls on a report to display the largest and smallest order amounts for a particular customer. Or you could use the DMin function in a query expression to display all orders with a discount greater than the minimum possible discount.
Syntax
DMin(expr, domain[, criteria])
DMax(expr, domain[, criteria])
You can use the DStDev and DStDevP functions to estimate the standard deviation across a set of values in a specified set of records (a domain). Use the DStDev and DStDevP functions in Visual Basic, a macro, a query expression, or a calculated control on a form or report.
Use the DStDevP function to evaluate a population, and the DStDev function to evaluate a population sample.
For example, you could use the DStDev function in a module to calculate the standard deviation across a set of students' test scores.
Syntax
DStDev(expr, domain[, criteria])
DStDevP(expr, domain[, criteria]
You can use the DSum functions to calculate the sum of a set of values in a specified set of records (a domain). Use the DSum function in Visual Basic, a macro, a query expression, or a calculated control.
For example, you could use the DSum function in a calculated field expression in a query to calculate the total sales made by a particular employee over a period of time. Or you could use the DSum function in a calculated control to display a running sum of sales for a particular product.
Syntax
DSum(expr, domain[, criteria])