ORDER BY Clause - Sort Data in SQL - 1keydata
ORDER BY Clause - Sort Data in SQL - 1keydata
SQL ORDER BY
Date Functions
SELECT Store_Name
FROM Store_Information
ORDER BY Sales DESC;
Store_Name
Los Angeles
Boston
San Francisco
San Diego
It is also possible to sort the result by an expression. For example, in the following table,
Table Product_Sales
we can use the following SQL to order the results by Revenue (defined as Price * Units):
Result:
Product_ID Revenue
1 90
3 75
2 60
Exercises
For these exercises, assume we have a table called User_Sales with the following data:
Table User_Sales
1. Which of the following SQL statement is valid? (There can be more than one answer)
a) SELECT * FROM User_Sales ORDER BY Sales;
b) SELECT * FROM User_Sales ORDER BY Last_Name DESC;
c) SELECT * FROM User_Sales ORDER BY First_Name WHERE Sales > 100;
d) SELECT * FROM User_Sales ORDER BY Last_Name, First_Name;
http://www.1keydata.com/sql/sqlorderby.html 2/3
3/2/2016 ORDER BY Clause Sort Data In SQL | 1Keydata
Show Answers
Start Download
Convert Any File to a PDF. Get the Free From Doc to Pdf App!
Copyright © 2016 1keydata.com All Rights Reserved Privacy Policy About Contact
http://www.1keydata.com/sql/sqlorderby.html 3/3