Lab 3.5 - MOAR SQL

Ranae Dietzel & Andee Kaplan

Lab 3.5 - MOAR SQL

Commands you may need

Subqueries

A subquery is a SELECT statement nested in another statement.

select trackid,
       name,
       albumid
from track
where albumid = (
                     select albumid
                     from album
                     where title = 'Nevermind'
                 );

Here, select albumid from album where title = 'Nevermind' is the subquery that lets us grab the albumid for Nirvana’s Nevermind album.

Your Turn

Continue working with the Chinook database to answer the following questions. For reference, http://www.sqlitetutorial.net/

  1. Which artists did not make any albums at all?
  2. Which artist has the most albums?
  3. Which video track has the longest length?
  4. How many distinct customers purchased audio tracks from each country? How many audio tracks did they purchase and what was the total price (by country)?
  5. Find the names of customers who live in the same city as the top employee in the hierarchy. What about the same country?