Database Reference
In-Depth Information
HEADING "Outstanding"
SELECT A.NAME AS ARTIST
, SUM(ST.AMOUNT_CHARGED) - SUM(ST.AMOUNT_PAID) AS OUTSTANDING
FROM STUDIOTIME ST NATURAL JOIN ARTIST A
GROUP BY A.NAME;
Sorting with the GROUP BY Clause
Did you notice how rows were sorted by the name of the artist in Figure
11.12? The GROUP BY clause will sort by the elements listed in the
GROUP BY clause. Let's change that sort order by changing the GROUP
BY clause. The result of the following query is shown in Figure 11.13.
COLUMN ARTIST FORMAT A24 HEADING "Artist"
COLUMN EMAIL FORMAT A24 HEADING "Email Address"
COLUMN OUTSTANDING FORMAT $999990.00 -
HEADING "Outstanding";
SELECT A.NAME AS ARTIST, A.EMAIL AS EMAIL
, SUM(ST.AMOUNT_CHARGED) - SUM(ST.AMOUNT_PAID) AS OUTSTANDING
FROM STUDIOTIME ST NATURAL JOIN ARTIST A
GROUP BY A.EMAIL, A.NAME;
Figure 11.13
Changing the Sort
Order Using the
GROUP BY
Clause.
Search WWH ::




Custom Search