Select top in MS SQL Server Last Updated : 09 Jul, 2020 Comments Improve Suggest changes Like Article Like Report Prerequisite - Select in MS SQL Server Suppose that a user wants to extract the top students from the whole institution but has to use some complex queries to extract the data. To avoid complexity, the user can use 'Select Top'. 'Select Top' extracts the limited number of rows. This results in accurate data along with less time consumption. Syntax - select top (expression) [percent] [with ties] from table_name order by column_name Analyzing the Syntax - Top is a keyword that extracts the data from the top of the list. Expression is the data that is to be extracted from the table. Percent is the number of rows that need to be extracted from the table. With Ties returns the rows that share the same values with the last row. In some cases, more rows can be retrieved. The order by clause is used for arranging the data in a chronological order. It is mandatory to use this clause in syntax otherwise, it results in an error. Example - If a user wants to extract the top 5 students of an institution, the query is written as - select top 5 name rollnumber gpa from student order by name ASC Output - Roll number Name GPA 114 Aisha 9.5 116 Apoorva 9.4 119 Mina 8.7 114 Rita 8.1 118 Veena 7.7 This way the desired data can be extracted. The last row student has a gpa of 7.7 and if there are a few more students that share the same numbers, the query must be written as - select top 8 with ties name rollnumber gpa from student order by name ASC Output - Roll number Name GPA 114 Aisha 9.5 116 Apoorva 9.4 119 Mina 8.7 114 Rita 8.1 118 Veena 7.7 110 Vinitha 7.7 101 Yamini 7.7 107 Zubaida 7.7 ASC arranges the data from ascending to descending order. DESC can be used if the data has to be arranged from descending to ascending order. Comment More infoAdvertise with us Next Article Select top in MS SQL Server M mangalgiaishwarya2 Follow Improve Article Tags : DBMS SQL DBMS-SQL mysql Similar Reads Select Statement in MS SQL Server The SELECT statement in SQL Server is a foundational SQL command used for querying and retrieving data from one or more tables within a database. This command allows users to specify which columns and rows to retrieve and apply filters to focus on specific data and perform various operations to mani 4 min read SET vs SELECT in SQL In SQL, SET and SELECT are powerful commands that are commonly used for assigning values to variables and retrieving data. While both are essential, they serve different purposes and are optimized for different scenarios. Understanding the differences between these two commands can greatly enhance o 5 min read Joins in MS SQL Server A database comprises tables and each table in case of RDBMS is called a relation. Let us consider a sample database named University and it has two tables named Student and Marks. If a user wants to transfer a certain set of rows, insert into select statement is used along with the query. But if a u 2 min read Insert Into Select statement in MS SQL Server The INSERT INTO SELECT statement in SQL Server is a versatile feature that enables you to efficiently copy data from one or more tables into another table. This functionality is essential for tasks such as data transfer, backup creation, and data merging.In this article, We will learn to Insert Into 4 min read How to Limit Rows in a SQL Server? To limit rows in SQL Server, use the TOP clause in the SELECT statement. Using the TOP clause in SQL Server, users can limit the number of rows in the results set. Here, we will understand how to limit rows in SQL Server with the help of different examples. Steps to Limit Rows in SQL ServerLet's che 3 min read Like