Database Reference
In-Depth Information
Now add the BALANCE column to the ORDER BY list. This time,
you want to first sort by DUE_DATE and then by BALANCE within
DUE_DATE. BALANCE can be sorted in descending order. This way, the
top of your report shows you which artists owe you the most money for the
longest amount of time. The ORDER BY clause can be changed as shown:
ORDER BY DUE_DATE, BALANCE DESC;
Note:
The column alias is not included in this code snippet. An alias is
optional in the ANSI standard natural join. Joins are covered in Chapter 10.
Figure 6.3 shows the query and results in descending order of BAL-
ANCE within ascending order by DUE_DATE.
That covers the basics of sorting in ascending order, descending order,
and using one or more columns. Now let's look at some slightly more com-
plex aspects of sorting. We begin with looking at the behavior of null values
when sorting.
Figure 6.3
Sorting by Multiple
Columns.
Search WWH ::




Custom Search