First, Last Functions (Microsoft Jet SQL)

Microsoft Jet SQL Reference

First, Last Functions

Return a field value from the first or last record in the result set returned by a query.

Syntax

First(expr)

Last(expr)

The expr placeholder represents a string expression identifying the field that contains the data you want to use or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

The First and Last functions are analogous to the MoveFirst and MoveLast methods of a DAO Recordset object. They simply return the value of a specified field in the first or last record, respectively, of the result set returned by a query. Because records are usually returned in no particular order (unless the query includes an ORDER BY clause), the records returned by these functions will be arbitrary.

See Also
Calculating Fields in SQL Functions SQL Aggregate Functions (SQL)
Example

First, Last Functions Example