SQL SELECT FIRST

The SQL FIRST() function returns the first value of the selected column.

SQL SELECT FIRST Syntax

Let’s check the syntax of the SQL SELECT FIRST() function:

SELECT FIRST(column_name) FROM table_name;

In this syntax,

  1. The function FIRST() takes column_name as a parameter.
  2. column_name – The name of the column from which you want to check the first value.
  3. table_name – The name of the table from which you want to check the data.

Note that the first() function is only supported by MS Access. The function does not work with other database like Microsoft SQL Server, Oracle or MySQL.

SQL SELECT FIRST Example

We will consider below Employee table for our reference and example.

emp_id emp_name emp_gender dept_code emp_location
1510 Avinash Sirsath M 101 Mumbai
1511 Ramjan Ali M 105 Kolkata
1513 Piyam mondal M 101 Kolkata
1514 Jitu Garg M 104 Mumbai
1515 Raman Sahani M 105 Delhi
1517 Prakash Javedkar M 101 Delhi
1519 Pallab Das M 103 Kolkata
1520 Pankaj Sharma M 101 Bangalore

To get the first employee name from the Employee table, you can write the below query.

SELECT FIRST(emp_name) AS First_Employee FROM Employee;

Once the above query executed, it will show the below result.

Avinash Sirsath

Summary: In this tutorial, you have learned about the SQL SELECT FIRST() function. Note that this is only work with MS Access Database.

 

Leave a Comment