Worked Examples · Example 10
Q.Write an SQL query to display the Name and Marks of all students, arranged in descending order of Marks, from the Student table.
Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
93% · 13/14 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →To sort the output of a SELECT statement we add the ORDER BY clause, naming the field to sort on. DESC gives descending order (highest first); ASC (the default) gives ascending order.
Here we want the Name and Marks of all students, sorted from the highest marks down, so:
- Name the columns:
SELECT Name, Marks. - Give the table:
FROM Student. - Sort descending on marks:
ORDER BY Marks DESC.
The complete query is:
SELECT Name, Marks FROM Student
ORDER BY Marks DESC;
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.