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

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad
2 Bharath White Field Bangalore
3 Goutham Avenue colony Chennai
4 Bhargav James street Chennai
5 Varun Park Avenue Mumbai


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:

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad
2 Bharath White Field Bangalore