Sorting the result using Order By clause:
ORDER BY clause is used to sort the data fetched using select statement either in ascending order or in descending. By default data fetched is sorted in ascending order.
Syntax:
Select columnname(s) from tablename ORDER BY columnname [ ASC | DESC ];
Example:
SELECT City FROM Employee WHERE Name = 'Max' ORDER BY City ASC;
It will return all City of those employee whose name is Max and City will sort in Ascending order.
SELECT City FROM Employee WHERE Name = 'Max' ORDER BY City DESC;
Similarly it will also return city but in descending order.
0 Comment(s)