Lab 6. More Aggregations
CS122, Fall 2011


(15pt) Complete the following queries in SQL. Please put your queries in an SQL script file lab6.sql and upload it to CSNS at the end of the lab. 

1. List each artist name and the average length of the tracks recorded by the artist - display 0 for the artists who have not recorded any tracks. The average length of the tracks should be  rounded to seconds, and the results should be ordered by the average track length in descending order.

2. List the number of artists who came into the system each month in the last ten years. The results should include year, month, and the number of artists who came into the system in that month. The results should be ordered first by year and then by month, both in ascending order. Months in which no artists came in do not need to be included.

3. List the name of each salesperson and the number of members who are under the charge of either this salesperson, or a salesperson supervised by this salesperson.

4. Find the "Alternative Music Capital of the World", which is the city in which the largest number of  Alternative tracks were produced. The result should be in the form of "City, Region, Country". You must use the equi-join syntax for this query.

5. Find the top 3 members who have recorded the most number of tracks. The results should include the member name in the form of "FirstName LastName" and the numbers of tracks they recorded. You must use the inner join syntax for this query.