SQL Select top

SQL SELECT TOP statement is used to select the top data from a table. The SELECT TOP statement is used on large data tables which make it easier to retrieve or select the data.

SELECT TOP is not supported in all databases.

Let’s see the syntax of SELECT TOP Statement

SELECT TOP number column_name
FROM table_name;

 

Example:

Let us take a Student table with 5 student’s data

StudentIDStudent_NameAddressCity
1NithinBank StreetHyderabad
2BharathWhite FieldBangalore
3GouthamAvenue colonyChennai
4BhargavJames streetChennai
5VarunPark AvenueMumbai


Now, we shall select the top 2 rows from the table using SELECT TOP statement.

SELECT TOP 2 * FROM Student;

 

It displays the output as follows:

StudentIDStudent_NameAddressCity
1NithinBank StreetHyderabad
2BharathWhite FieldBangalore