In this chapter you will learn:
About order by statement
Syntax of order by statement
Example of order by statement
About order by statement
SQL order by statement is used to retrieve data from database table in ascending or descending order. By default retrieved data is displayed in assending order but if you want to display the data in decending order then you can use it.
Syntax of order by statement
Select * from table_name where condition order by column_name (ASC|DESC)
In the given syntax ASC is used for ascending order and DESC for descending order
Example of order by
select * from humanresources.employee order by employeeid asc
select * from humanresources.employee order by employeeid desc
SUMMARY
In this chapter, you have learned about order by statement so try to use it yourself. In the next chapter you will learn about GROUP BY statement.