How To Sort Output in Descending Order?
Page 1 of 1
How To Sort Output in Descending Order?
If you want to sort a column in descending order, you can specify the DESC keyword in the
ORDER BY clause. The following SELECT statement first sorts the department in descending
order, then sorts the salary in ascending order:
SQL> SELECT department_id, first_name, last_name, salary
FROM employees ORDER BY department_id DESC, salary;
DEPARTMENT_ID FIRST_NAME LAST_NAME SALARY
------------- --------------- --------------- ----------
Kimberely Grant 7000
110 William Gietz 8300
110 Shelley Higgins 12000
100 Luis Popp 6900
100 Ismael Sciarra 7700
100 Jose Manuel Urman 7800
100 John Chen 8200
100 Daniel Faviet 9000
ORDER BY clause. The following SELECT statement first sorts the department in descending
order, then sorts the salary in ascending order:
SQL> SELECT department_id, first_name, last_name, salary
FROM employees ORDER BY department_id DESC, salary;
DEPARTMENT_ID FIRST_NAME LAST_NAME SALARY
------------- --------------- --------------- ----------
Kimberely Grant 7000
110 William Gietz 8300
110 Shelley Higgins 12000
100 Luis Popp 6900
100 Ismael Sciarra 7700
100 Jose Manuel Urman 7800
100 John Chen 8200
100 Daniel Faviet 9000
Similar topics
» How To Sort the Query Output?
» How To Set Up SQL*Plus Output Format?
» How To Name Query Output Columns?
» How To Divide Query Output into Groups?
» Can the Query Output Be Sorted by Multiple Columns?
» How To Set Up SQL*Plus Output Format?
» How To Name Query Output Columns?
» How To Divide Query Output into Groups?
» Can the Query Output Be Sorted by Multiple Columns?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sun Jan 31, 2010 12:35 am by Micheal
» Accessing tables of other users in SQL
Sun Jan 31, 2010 12:34 am by Micheal
» Grouping commands in SQL
Sun Jan 31, 2010 12:32 am by Micheal
» Operations on Result Sets in SQL
Sun Jan 31, 2010 12:31 am by Micheal
» Subqueries in SQL
Sun Jan 31, 2010 12:30 am by Micheal
» Joining Relations in SQL
Sun Jan 31, 2010 12:28 am by Micheal
» Delete comand in SQL
Sun Jan 31, 2010 12:27 am by Micheal
» Update command in SQL
Sun Jan 31, 2010 12:26 am by Micheal
» Insert command in SQL
Sun Jan 31, 2010 12:23 am by Micheal