English

Execute the following two queries and find out what will happen if we specify two columns in the ORDER BY clause:

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?
Chapter 8: Introduction to Structured Query Language (SQL) - Intext Questions [Page 164]

APPEARS IN

NCERT Informatics Practices [English] Class 11
Chapter 8 Introduction to Structured Query Language (SQL)
Intext Questions | Q 18. | Page 164
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×