Can the Query Output Be Sorted by Multiple Columns in Oracle?
Submitted by: AdministratorYou can specifying multiple columns in the ORDER BY clause as shown in the following example statement, which returns employees' salaries sorted by department and salary value:
SQL> SELECT department_id, first_name, last_name, salary
FROM employees ORDER BY department_id, salary;
<pre>DEPARTMENT_ID FIRST_NAME LAST_NAME SALARY
------------- --------------- --------------- ----------
10 Jennifer Whalen 4400
20 Pat Fay 6000
20 Michael Hartstein 13000
30 Karen Colmenares 2500
30 Guy Himuro 2600
30 Sigal Tobias 2800
30 Shelli Baida 2900
30 Alexander Khoo 3100
30 Den Raphaely 11000
40 Susan Mavris 6500
50 TJ Olson 2100
......</pre>
Submitted by: Administrator
SQL> SELECT department_id, first_name, last_name, salary
FROM employees ORDER BY department_id, salary;
<pre>DEPARTMENT_ID FIRST_NAME LAST_NAME SALARY
------------- --------------- --------------- ----------
10 Jennifer Whalen 4400
20 Pat Fay 6000
20 Michael Hartstein 13000
30 Karen Colmenares 2500
30 Guy Himuro 2600
30 Sigal Tobias 2800
30 Shelli Baida 2900
30 Alexander Khoo 3100
30 Den Raphaely 11000
40 Susan Mavris 6500
50 TJ Olson 2100
......</pre>
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Write Date and Time Interval Literals in Oracle? |
☺ | How Run SQL*Plus Commands That Are Stored in a Local File? |
☺ | How To Recover a Dropped Table in Oracle? |
☺ | How To Shutdown Your 10g XE Server? |
☺ | What Is a Table Index in Oracle? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |