SQL server is the most popular database of microsoft company which was develop in 1989. SQL stands for Structure Query Language. It is RDBMs so in this case record is store in tabular format. It is platform dependent because it runs only on windows operating system.
ORDER BY CLAUSE WITH ASCENDING ORDER
Ascending order is use to sort data in ascending order. SQL ORDER BY query takes ascending order by default is knows as Ascending order statement in SQL
Syntax
SELECT ColumnName1,...,ColumnNameN FROM TableName ORDER BY ColumnName ASC;
Example of ORDER BY CLAUSE WITH ASCENDING ORDER
SELECT * FROM test.person2 order by Name;
Output of ORDER BY CLAUSE WITH ASCENDING ORDER
ORDER BY CLAUSE WITH DESCENDING ORDER
Descending order statement is use to sort data in descending order. You should use the DESC attribute in your ORDER BY clause is knows as Descending order in SQL
Syntax
SELECT ColumnName1,...,ColumnNameN FROM TableName ORDER BY ColumnNameDESC;
Example of ORDER BY CLAUSE WITH DESCENDING ORDER
SELECT * FROM test.person2 order by Name DESC;
Output of ORDER BY CLAUSE WITH DESCENDING ORDER
ORDER BY CLAUSE WITH RANDOM ORDER
It is use to sort records in random order in SQL Server is knows as Random order in SQL
Syntax
SELECT column FROM table ORDER BY RAND () LIMIT 1
Example of ORDER BY CLAUSE WITH RANDOM ORDER
SELECT Name FROM test.person2 order by rand() limit 1;
Output of ORDER BY CLAUSE WITH RANDOM ORDER
ORDER BY CLAUSE WITH LIMIT ORDER
Syntax
SELECT * FROM table_name limit ;
Example of ORDER BY CLAUSE WITH LIMIT ORDER
SELECT * FROM test.student_details limit 5;
Output ORDER BY CLAUSE WITH LIMIT ORDER
If you have any queries regarding this article or if I have missed something on this topic, please feel free to add in the comment down below for the audience. See you guys in another article.
To know more about SQL please Wikipedia click here .
Stay Connected Stay Safe, Thank you
0 Comments