VOOZH about

URL: https://www.geeksforgeeks.org/sql/first-and-lastfunction-in-ms-access/

⇱ First() and Last()Function in MS Access - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

First() and Last()Function in MS Access

Last Updated : 14 Sep, 2020
1. First() Function : In MS Access, the First() function is used to return a field value from the first record in the result set returned by a query. Syntax :
First(expr)
Parameter :
  • expr : It represents a string expression identifying the field that contains the data we want to use or an expression that performs a calculation using the data in that field.
Returns : It returns the first record in the result set. Example-1 :
SELECT First(Emp_id) AS EmployeeId FROM Employee_Details;
Output :
EmployeeId
101
Example-2 :
SELECT First(Emp_Name) AS FirstEmployee FROM Employee_Details;
Output :
FirstEmployee
Amit
2. Last() Function : In MS Access, the Last() function is used to return a field value from the last record in the result set returned by a query. Syntax :
Last(expr)
Parameter :
  • expr : It represents a string expression identifying the field that contains the data we want to use or an expression that performs a calculation using the data in that field.
Returns : It returns the last record in the result set. Example-2 :
SELECT Last(Emp_id) AS EmployeeId FROM Employee_Details;
Output :
EmployeeId
103
Example-2 :
SELECT Last(Emp_Name) AS LastEmployee FROM Employee_Details;
Output :
LastEmployee
Suhani
Comment
Article Tags:
Article Tags: