Database Reference
In-Depth Information
Figure 11.8
Number of Studio
Visits for All
Artists.
The ORDER BY clause is sorting using the result of the COUNT
function.
Now we execute the same query by applying the DISTINCT clause
modifier to the COUNT function as shown in the next query, to see
the difference.
SELECT A.ARTIST_ID, A.NAME "Artist"
, COUNT(DISTINCT ST.ARTIST_ID) "Studio Visits"
FROM ARTIST A, STUDIOTIME ST
WHERE A.ARTIST_ID = ST.ARTIST_ID(+)
GROUP BY A.ARTIST_ID, A.NAME
ORDER BY COUNT(DISTINCT ST.ARTIST_ID) DESC;
 
Search WWH ::




Custom Search