MIN {Expression}
The MIN function returns the smallest value in the specified field.
Use MIN to calculate the smallest value for a numeric, date, time, or timestamp field. As an aggregate function, MIN performs its calculation aggregating values in the same field across all rows in a dataset. The dataset can be the entire table, a filtered dataset, or a logical group produced by a GROUP BY clause. Field values of zero are included in the aggregation. NULL field values are not counted in the calculation. If the number of qualifying rows is zero, MIN returns a NULL value.
MIN function syntax has these named arguments:
Parameter |
Description |
|---|---|
Expression |
Required. The field reference or expression to return the minimum of. |
For example:
SELECT MIN(GrossAmount) FROM INHEAD
When used with a GROUP BY clause, MIN returns one calculation value for each group. This value is the aggregation of the specified field for all rows in each group. The following example aggregates the smallest value for the GrossAmount field in the INHEAD table, producing a subtotal for each Customer in the ARCUST table:
SELECT C.CustomerCode , AVG(H.GrossAmount) as Average, MAX(H.GrossAmount) as Biggest, MIN(H.GrossAmount) as Smallest
FROM ARCUST C, INHEAD H
WHERE C.CustomerCode = H.CustomerCode
GROUP BY C.CustomerCode
ORDER BY C.CustomerCode