Order by in MS SQL Server Last Updated : 05 Jun, 2020 Comments Improve Suggest changes Like Article Like Report In this article, order by and terms related to order by will be discussed. Introduction - There are some instances where the tables are to be arranged in a chronological order. While the users use the select statement to retrieve rows, one cannot guarantee that the rows are arranged in an order. To solve this, order by clause is being used. Basic syntax: select select_list from table_name order by Example: Sample table-Student Roll number Name Course 111 Riya CSE 112 Apoorva ECE 113 Mina Mech 114 Rita Biotechnology 115 Veena Chemical 116 Deepa EEE If a user wants to arrange the names in an order then the query must be written as follows: select roll number name course from student order by name The output is: Roll number Name Course 112 Apoorva ECE 116 Deepa EEE 113 Mina Mech 114 Rita Biotechnology 111 Riya Biotechnology 115 Veena Chemical Note that the table is arranged in ascending order by default using the order by clause. ASC | DESC : A user can arrange the columns in ascending or descending order using ASC or DESC respectively. ASC arranges the columns from lowest to highest DESC arranges the columns from highest to lowest. If there is a NULL column in the table, it will be treated as the lowest value. Comment More infoAdvertise with us Next Article Order by in MS SQL Server M mangalgiaishwarya2 Follow Improve Article Tags : DBMS SQL SQL-Server Similar Reads Offset-Fetch in MS SQL Server Suppose a table has 30 rows. A user wants to extract list of last 10 rows and skip topmost rows. To make job easier, the offset-fetch clause is used in the query. Syntax : order by column_list[ASC|DESC] Offset offset_row count{ROW|ROWS} Fetch{FIRST|NEXT} fetch row_count {ROW|ROWS} only Analysis of S 2 min read Select top in MS SQL Server 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 accur 2 min read Table operations in MS SQL Server In a relational database, the data is stored in the form of tables and each table is referred to as a relation. A table can store a maximum of 1000 rows. Tables are a preferred choice as: Tables are arranged in an organized manner. We can segregate the data according to our preferences in the form o 2 min read Group by clause in MS SQL Server Group by clause will be discussed in detail in this article. There are tons of data present in the database system. Even though the data is arranged in form of a table in a proper order, the user at times wants the data in the query to be grouped for easier access. To arrange the data(columns) in fo 3 min read Introduction of MS SQL Server Data is a collection of facts and figures and we have humungous data available to the users via the internet and other sources. To manipulate the data, Structured Query Language (SQL) in short has been introduced years ago. There are different versions of SQL available in the market provided by diff 2 min read SQL ORDER BY The ORDER BY clause in SQL is a powerful feature used to sort query results in either ascending or descending order based on one or more columns. Whether you're presenting data to users or analyzing large datasets, sorting the results in a structured way is essential. In this article, weâll explain 5 min read REVERSE() Function in SQL Server The REVERSE() function in SQL Server is a simple and powerful tool designed to reverse the order of characters in a string. By taking a string input, it returns a new string with its characters arranged in the opposite sequence. In this article, We will learn to REVERSE() Functions in SQL Server by 3 min read 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 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 RANK() Function in SQL Server The RANK() function is a powerful window function in SQL Server used to assign a rank to each row within a result set. It is particularly useful when we need to assign a rank to a group of rows based on some sorting criteria and want to differentiate between rows that have the same values. Unlike ot 5 min read Like