SQL ORDER BY Command

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
assending order
select * from humanresources.employee order by employeeid desc
decending order
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.

 

More Articles

 

Share your thought



PLEASE DISABLE ADBLOCKER AND SUPPORT US!

Please support us by enabling ads on this page. Refresh

YOU DON'T LIKE ADS, WE ALSO DON'T LIKE ADS!
 
But we have to show ads on our site to keep it free and updated. We have to pay huge server costs, domain costs, CDN Costs, Developer Costs, Electricity and Internet Bill. Your little contribution will encourage us to regularly update this site.