Advertisements
Advertisements
Question
Execute the following two queries and find out what will happen if we specify two columns in the ORDER BY clause:
SELECT *
FROM EMPLOYEE
ORDER BY Salary,
Bonus;
SELECT *
FROM EMPLOYEE
ORDER BY Salary,Bonus
desc;Code Writing
Advertisements
Solution
SELECT *
FROM EMPLOYEE
ORDER BY Salary, Bonus;
Output: The records are arranged in ascending order of Salary. If two employees have the same Salary, they are arranged in ascending order of Bonus.
SELECT *
FROM EMPLOYEE
ORDER BY Salary, Bonus DESC;
Output: The records are arranged in ascending order of Salary. If two employees have the same Salary, they are arranged in descending order of Bonus.
DESC applies only to Bonus, the column immediately before it.
shaalaa.com
Is there an error in this question or solution?
