Question:

In the following Query, which of the following can be placed in the Query's blank portion to display the salary from highest to lowest amount, and sorting the employees' names alphabetically?
SELECT * FROM instructor
ORDER BY salary .................... , name .................... ;

Show Hint

When sorting by multiple columns in SQL, specify the order for each column separately in the ORDER BY clause.
  • Ascending, Descending
  • Asc, Desc
  • Desc, Asc
  • All of the above
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: In SQL, the ORDER BY clause is used to sort query results in ascending (ASC) or descending (DESC) order.
Step 2: The requirement is: - Salary should be sorted from highest to lowest → Descending order.
- Employee names should be sorted alphabetically → Ascending order.
Step 3: The correct syntax becomes: \[ ORDER BY salary DESC, name ASC; \] Step 4: Checking the options:
- (A) "Ascending, Descending" is incorrect because salary needs to be descending and name ascending.
- (B) "Asc, Desc" is the reverse of the requirement.
- (C) "Desc, Asc" matches perfectly.
- (D) "All of the above" is incorrect because only option (C) meets the requirement.
Thus, the correct choice is $\mathbfDesc, Asc$.
Was this answer helpful?
0
0