Databases Reference
In-Depth Information
112................................Urman
144...............................Vargas
162..............................Vishney
196................................Walsh
120................................Weiss
200...............................Whalen
149..............................Zlotkey
107 rows selected.
The column or columns to be sorted don't necessarily need to be in the
SELECT clause. If there are NULL values in a column to be sorted, they will
appear at the end if the sort is ascending, and they will appear first if the sort
is descending.
As you might expect, you can combine both ascending and descending sorts
in the same ORDER BY clause. The president, King, needs a monthly report that
shows the salaries for each department, in ascending order of department num-
ber but in descending order for the salary amount. Janice comes up with the fol-
lowing query for King:
select department_id "Dept",
last_name || ', ' || first_name "Employee",
salary "Salary" from employees
order by department_id asc, salary desc;
Dept Employee Salary
----- ------------------------------ ----------
10 Whalen, Jennifer 4400
20 Hartstein, Michael 13000
20 Fay, Pat 6000
30 Raphaely, Den 11000
30 Khoo, Alexander 3100
30 Baida, Shelli 2900
30 Tobias, Sigal 2800
30 Himuro, Guy 2600
30 Colmenares, Karen 2500
40 Mavris, Susan 6500
...
90 King, Steven 24000
90 Kochhar, Neena 17000
Search WWH ::




Custom Search