SQL SELECT FIRST

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

syntax of sql select first() function:

SELECT FIRST(column_name) FROM table_name;

Note: The FIRST() function is only supported in MS Access.

SQL FIRST() in SQL Server, MySQL and Oracle

Example

SELECT TOP 1 CustomerName FROM Customers

ORDER BY CustomerID ASC;

Syntax of MySQL

SELECT column_name FROM table_name

ORDER BY column_name ASC

LIMIT 1;

Example

SELECT CustomerName FROM Customers

ORDER BY CustomerID ASC

LIMIT 1;

Syntax of Oracle

SELECT column_name FROM table_name

WHERE ROWNUM <=1

ORDER BY column_name ASC;

Example

SELECT CustomerName FROM Customers

WHERE ROWNUM <=1

ORDER BY CustomerID ASC;

If you want to retrieve the first value of the "customer_name" column from the "customers" table, you need to write following query:

SELECT FIRST(customer_name) AS first_customer FROM customers;

Let us take the example of CUSTOMERS to examine SQL SELECT FIRST command:

Table Customer

Customer_Name Age Address Expenditure
Mithiilesh singh 25 Noida 5000
Neha 26 Japan 59000
Rahul 56 Delhi 65000

If you want to retrieve the first value of the "customer_name" column from the "customers" table, you need to write following query:

Let's see the syntax of sql select first() function:

SELECT FIRST (CUSTOMER_NAME) AS first_customer FROM CUSTOMERS;

After that query, you will find the result:

Mithilesh Singh