JetSQL » Functions » LAST

Syntax:
SELECT LAST(field) AS [expression]
FROM table
[WHERE ...]
[GROUP BY ...]
[ORDER BY ...]

The LAST function is used to return the value of the last record in the designated field. Therefore, this function returns a single value.

Since the records are returned in an arbitrary order, the last record will also be arbitrary. You can use the ORDER BY clause to order the records.

The companion FIRST function returns the first record in the designated field.

Examples

Code:
SELECT LAST(birthdate) AS LastBirthDate
FROM MediCarePatients
ORDER BY age
Explanation:

This code finds the last birthdate in a table of MediCare patients that is ordered by the age field.

Language(s): MS SQL Server

See Also: