The DESC command is used to sort the data returned in descending order.When sorting your result set in descending order, you use the DESC attribute in your ORDER BY clause. For example: SELECT last_name FROM employees WHERE first_name = 'Sarah' ORDER BY last_name DESC; This SQL Server ORDER BY example would return all records sorted by the last_name field in descending order.To sort textual data alphabetically using the SQL ORDER BY clause, you can either use the ASC (ascending) or DESC (descending) keywords, which will sort the data in alphabetical (A-Z) or reverse-alphabetical (Z-A) order, respectively.
What is DESC sorting : Descending order means the largest or last in the order will appear at the top of the list: For numbers or amounts, the sort is largest to smallest. Higher numbers or amounts will be at the top of the list.
How to use DESC command in SQL
A desc command is also called a describe command in SQL. The command is case-insensitive and can be used in any of the below forms. Desc Table_Name; The above two commands perform the same function and will produce the same result.
How to SELECT DESC in SQL query : Here in a SELECT query, an ORDER BY clause is applied on the column 'Name' to sort the records. DESC keyword will sort the records in descending order. All the records present in the customers table are displayed in the descending order of the customer's name.
A desc command is also called a describe command in SQL. The command is case-insensitive and can be used in any of the below forms. Desc Table_Name; The above two commands perform the same function and will produce the same result.
Here in a SELECT query, an ORDER BY clause is applied on the column 'Name' to sort the records. DESC keyword will sort the records in descending order. All the records present in the customers table are displayed in the descending order of the customer's name.
What is the use of DESC
DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in descending order.To sort list items in descending order, you need to use the optional reverse parameter with the sort() method, and set its value to True .We can use it as below:
- EXEC sp_help 'dbo.mytable';
- EXEC sp_help 'dbo.Users';
- EXEC sp_columns mytable;
- EXEC sp_columns Users;
- SELECT * FROM information_schema.columns WHERE table_name = 'object_name';
- SELECT * FROM information_schema.columns WHERE table_name = 'Users';
A desc command is also called a describe command in SQL. The command is case-insensitive and can be used in any of the below forms. Desc Table_Name; The above two commands perform the same function and will produce the same result.
How to count ORDER BY desc in mysql : Use ORDER BY with DESC to order in descending order. For counting the values, use the COUNT(). For example, if the name “John” appears thrice in the column, then a separate column will display the count 3 and in this way all the count values will be arranged in descending order using the ORDER BY DESC.
What is ORDER BY desc : Descending order means the largest or last in the order will appear at the top of the list: For numbers or amounts, the sort is largest to smallest. Higher numbers or amounts will be at the top of the list.