db_id
stringclasses
146 values
question_en
stringlengths
3
224
hardness
stringclasses
4 values
schema_llm
stringclasses
146 values
query_llm
stringlengths
18
631
schema_llm_min
stringclasses
147 values
schema_dict
stringclasses
146 values
tables_and_columns
stringlengths
18
266
schema_reduzido
stringlengths
25
718
schema_reduzido_only_tables
stringlengths
80
2.27k
coffee_shop
What are the average score and average staff number of all shops?
medium
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT avg(num_of_staff) , avg(score) FROM shop
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'shop': ['shop_id', 'num_of_staff', 'score'] }
TABLE shop ( shop.Shop_ID (INT), shop.Num_of_staff (TEXT), shop.Score (REAL), ) Possible JOINs:
TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs:
coffee_shop
Find the id and address of the shops whose score is below the average score.
extra
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT shop_id , address FROM shop WHERE score < (SELECT avg(score) FROM shop)
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'shop': ['shop_id', 'address', 'score'] }
TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Score (REAL), ) Possible JOINs:
TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs:
coffee_shop
Find the address and staff number of the shops that do not have any happy hour.
extra
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT address , num_of_staff FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM happy_hour)
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'shop': ['shop_id', 'address', 'num_of_staff'], 'happy_hour': ['hh_id', 'shop_id'] }
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), ) TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), )
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID
coffee_shop
What are the id and address of the shops which have a happy hour in May?
medium
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT shop.address , shop.shop_id FROM shop JOIN happy_hour ON shop.shop_id = happy_hour.shop_id WHERE MONTH = 'May'
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'shop': ['shop_id', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month'] }
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), ) TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), )
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) TABLE shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID
coffee_shop
which shop has happy hour most frequently? List its id and number of happy hours.
hard
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT shop_id , count(*) FROM happy_hour GROUP BY shop_id ORDER BY count(*) DESC LIMIT 1
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'happy_hour': ['hh_id', 'shop_id'] }
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), )
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID
coffee_shop
Which month has the most happy hours?
hard
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT MONTH FROM happy_hour GROUP BY MONTH ORDER BY count(*) DESC LIMIT 1
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'happy_hour': ['hh_id', 'month'] }
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Month (TEXT), )
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID
coffee_shop
Which months have more than 2 happy hours?
easy
Table happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.HH_ID (INT), happy_hour_member.Member_ID (INT), happy_hour_member.Total_amount (REAL), ) Table member ( member.Member_ID (INT), member.Name (TEXT), member.Membership_card (TEXT), member.Age (INT), member.Time_of_purchase (INT), member.Level_of_membership (INT), member.Address (TEXT), ) Table shop ( shop.Shop_ID (INT), shop.Address (TEXT), shop.Num_of_staff (TEXT), shop.Score (REAL), shop.Open_Year (TEXT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID happy_hour_member.Member_ID = member.Member_ID
SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING count(*) > 2
Table happy_hour ( happy_hour.hh_id (INT), happy_hour.shop_id (INT), happy_hour.month (TEXT), happy_hour.num_of_shaff_in_charge (INT), ) Table happy_hour_member ( happy_hour_member.hh_id (INT), happy_hour_member.member_id (INT), happy_hour_member.total_amount (REAL), ) Table member ( member.member_id (INT), member.name (TEXT), member.membership_card (TEXT), member.age (INT), member.time_of_purchase (INT), member.level_of_membership (INT), member.address (TEXT), ) Table shop ( shop.shop_id (INT), shop.address (TEXT), shop.num_of_staff (TEXT), shop.score (REAL), shop.open_year (TEXT), ) Possible JOINs: happy_hour.shop_id = shop.shop_id happy_hour_member.member_id = member.member_id
{ 'shop': ['shop_id', 'address', 'num_of_staff', 'score', 'open_year'], 'member': ['member_id', 'name', 'membership_card', 'age', 'time_of_purchase', 'level_of_membership', 'address'], 'happy_hour': ['hh_id', 'shop_id', 'month', 'num_of_shaff_in_charge'], 'happy_hour_member': ['hh_id', 'member_id', 'total_amount'] }
{ 'happy_hour': ['hh_id', 'month'] }
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Month (TEXT), )
TABLE happy_hour ( happy_hour.HH_ID (INT), happy_hour.Shop_ID (INT), happy_hour.Month (TEXT), happy_hour.Num_of_shaff_in_charge (INT), ) Possible JOINs: happy_hour.Shop_ID = shop.Shop_ID
chinook_1
How many albums are there?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT count(*) FROM ALBUM
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid'] }
TABLE Album ( Album.AlbumId (INTEGER), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Find the number of albums.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT count(*) FROM ALBUM
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid'] }
TABLE Album ( Album.AlbumId (INTEGER), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
List the names of all music genres.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM GENRE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Possible JOINs:
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Possible JOINs:
chinook_1
What are the names of different music genres?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM GENRE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Possible JOINs:
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Possible JOINs:
chinook_1
Find all the customer information in state NY.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT * FROM CUSTOMER WHERE State = "NY"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'state'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.State (varchar(40)), )
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId
chinook_1
What is all the customer information for customers in NY state?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT * FROM CUSTOMER WHERE State = "NY"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'state'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.State (varchar(40)), )
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId
chinook_1
What are the first names and last names of the employees who live in Calgary city.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT FirstName , LastName FROM EMPLOYEE WHERE City = "Calgary"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'lastname', 'firstname', 'city'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.City (varchar(40)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
Find the full names of employees living in the city of Calgary.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT FirstName , LastName FROM EMPLOYEE WHERE City = "Calgary"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'lastname', 'firstname', 'city'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.City (varchar(40)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
What are the distinct billing countries of the invoices?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT distinct(BillingCountry) FROM INVOICE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'invoice': ['invoiceid', 'billingcountry'] }
TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.BillingCountry (varchar(40)), )
TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Invoice.CustomerId = Customer.CustomerId
chinook_1
Find the different billing countries for all invoices.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT distinct(BillingCountry) FROM INVOICE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'invoice': ['invoiceid', 'billingcountry'] }
TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.BillingCountry (varchar(40)), )
TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Invoice.CustomerId = Customer.CustomerId
chinook_1
Find the names of all artists that have "a" in their names.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM ARTIST WHERE Name LIKE "%a%"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'artist': ['artistid', 'name'] }
TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs:
TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs:
chinook_1
What are the names of artist who have the letter 'a' in their names?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM ARTIST WHERE Name LIKE "%a%"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'artist': ['artistid', 'name'] }
TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs:
TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs:
chinook_1
Find the title of all the albums of the artist "AC/DC".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Title FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId WHERE ARTIST.Name = "AC/DC"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What are the titles of albums by the artist "AC/DC"?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Title FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId WHERE ARTIST.Name = "AC/DC"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Hom many albums does the artist "Metallica" have?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId WHERE ARTIST.Name = "Metallica"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Find the number of albums by the artist "Metallica".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId WHERE ARTIST.Name = "Metallica"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Which artist does the album "Balls to the Wall" belong to?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ARTIST.Name FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId WHERE ALBUM.Title = "Balls to the Wall"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Find the name of the artist who made the album "Balls to the Wall".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ARTIST.Name FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId WHERE ALBUM.Title = "Balls to the Wall"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Which artist has the most albums?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ARTIST.Name FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId GROUP BY ARTIST.Name ORDER BY COUNT(*) DESC LIMIT 1
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What is the name of the artist with the greatest number of albums?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ARTIST.Name FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId GROUP BY ARTIST.Name ORDER BY COUNT(*) DESC LIMIT 1
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Find the names of all the tracks that contain the word "you".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM TRACK WHERE Name LIKE '%you%'
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'name'] }
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What are the names of tracks that contain the the word you in them?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM TRACK WHERE Name LIKE '%you%'
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'name'] }
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the average unit price of all the tracks?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(UnitPrice) FROM TRACK
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'unitprice'] }
TABLE Track ( Track.TrackId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the average unit price for a track.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(UnitPrice) FROM TRACK
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'unitprice'] }
TABLE Track ( Track.TrackId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What are the durations of the longest and the shortest tracks in milliseconds?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'milliseconds'] }
TABLE Track ( Track.TrackId (INTEGER), Track.Milliseconds (INTEGER), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the maximum and minimum durations of tracks in milliseconds.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'milliseconds'] }
TABLE Track ( Track.TrackId (INTEGER), Track.Milliseconds (INTEGER), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Show the album names, ids and the number of tracks for each album.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ALBUM.Title , TRACK.AlbumID , COUNT(*) FROM ALBUM JOIN TRACK ON ALBUM.AlbumId = TRACK.AlbumId GROUP BY TRACK.AlbumID
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'], 'track': ['trackid', 'albumid'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), ) TABLE Track ( Track.TrackId (INTEGER), Track.AlbumId (INTEGER), ) Possible JOINs:
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What are the names and ids of the different albums, and how many tracks are on each?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ALBUM.Title , TRACK.AlbumID , COUNT(*) FROM ALBUM JOIN TRACK ON ALBUM.AlbumId = TRACK.AlbumId GROUP BY TRACK.AlbumID
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'], 'track': ['trackid', 'albumid'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), ) TABLE Track ( Track.TrackId (INTEGER), Track.AlbumId (INTEGER), ) Possible JOINs:
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the name of the most common genre in all tracks?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT GENRE.Name FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId GROUP BY TRACK.GenreId ORDER BY COUNT(*) DESC LIMIT 1
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the name of the genre that is most frequent across all tracks.
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT GENRE.Name FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId GROUP BY TRACK.GenreId ORDER BY COUNT(*) DESC LIMIT 1
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the least common media type in all tracks?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT MEDIATYPE.Name FROM MEDIATYPE JOIN TRACK ON MEDIATYPE.MediaTypeId = TRACK.MediaTypeId GROUP BY TRACK.MediaTypeId ORDER BY COUNT(*) ASC LIMIT 1
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'mediatype': ['mediatypeid', 'name'], 'track': ['trackid', 'mediatypeid'] }
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.MediaTypeId (INTEGER), )
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the name of the media type that is least common across all tracks?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT MEDIATYPE.Name FROM MEDIATYPE JOIN TRACK ON MEDIATYPE.MediaTypeId = TRACK.MediaTypeId GROUP BY TRACK.MediaTypeId ORDER BY COUNT(*) ASC LIMIT 1
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'mediatype': ['mediatypeid', 'name'], 'track': ['trackid', 'mediatypeid'] }
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.MediaTypeId (INTEGER), )
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Show the album names and ids for albums that contain tracks with unit price bigger than 1.
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ALBUM.Title , TRACK.AlbumID FROM ALBUM JOIN TRACK ON ALBUM.AlbumId = TRACK.AlbumId WHERE TRACK.UnitPrice > 1 GROUP BY TRACK.AlbumID
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'], 'track': ['trackid', 'albumid', 'unitprice'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), ) TABLE Track ( Track.TrackId (INTEGER), Track.AlbumId (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs:
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What are the titles and ids for albums containing tracks with unit price greater than 1?
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ALBUM.Title , TRACK.AlbumID FROM ALBUM JOIN TRACK ON ALBUM.AlbumId = TRACK.AlbumId WHERE TRACK.UnitPrice > 1 GROUP BY TRACK.AlbumID
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'], 'track': ['trackid', 'albumid', 'unitprice'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), ) TABLE Track ( Track.TrackId (INTEGER), Track.AlbumId (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs:
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
How many tracks belong to rock genre?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Rock"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Count the number of tracks that are part of the rock genre.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Rock"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the average unit price of tracks that belong to Jazz genre?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(UnitPrice) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Jazz"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'unitprice'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the average unit price of jazz tracks.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(UnitPrice) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Jazz"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'unitprice'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the first name and last name of the customer that has email "luisg@embraer.com.br"?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT FirstName , LastName FROM CUSTOMER WHERE Email = "luisg@embraer.com.br"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'lastname', 'email'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Email (varchar(60)), )
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId
chinook_1
Find the full name of the customer with the email "luisg@embraer.com.br".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT FirstName , LastName FROM CUSTOMER WHERE Email = "luisg@embraer.com.br"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'lastname', 'email'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Email (varchar(60)), )
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId
chinook_1
How many customers have email that contains "gmail.com"?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'email'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.Email (varchar(60)), )
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId
chinook_1
Count the number of customers that have an email containing "gmail.com".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'email'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.Email (varchar(60)), )
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId
chinook_1
What is the first name and last name employee helps the customer with first name Leonie?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT EMPLOYEE.FirstName , EMPLOYEE.LastName FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId WHERE CUSTOMER.FirstName = "Leonie"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
Find the full names of employees who help customers with the first name Leonie.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT EMPLOYEE.FirstName , EMPLOYEE.LastName FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId WHERE CUSTOMER.FirstName = "Leonie"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
What city does the employee who helps the customer with postal code 70174 live in?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT EMPLOYEE.City FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId WHERE CUSTOMER.PostalCode = "70174"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'postalcode', 'supportrepid'], 'employee': ['employeeid', 'city'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.PostalCode (varchar(10)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.City (varchar(40)), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
Find the cities corresponding to employees who help customers with the postal code 70174.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT EMPLOYEE.City FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId WHERE CUSTOMER.PostalCode = "70174"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'postalcode', 'supportrepid'], 'employee': ['employeeid', 'city'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.PostalCode (varchar(10)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.City (varchar(40)), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
How many distinct cities does the employees live in?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(DISTINCT city) FROM EMPLOYEE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'city'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.City (varchar(40)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
Find the number of different cities that employees live in.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(DISTINCT city) FROM EMPLOYEE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'city'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.City (varchar(40)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
Find all invoice dates corresponding to customers with first name Astrid and last name Gruber.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT INVOICE.InvoiceDate FROM CUSTOMER JOIN INVOICE ON CUSTOMER.CustomerId = INVOICE.CustomerId WHERE CUSTOMER.FirstName = "Astrid" AND LastName = "Gruber"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'lastname'], 'invoice': ['invoiceid', 'customerid', 'invoicedate'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
What are the invoice dates for customers with the first name Astrid and the last name Gruber?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT INVOICE.InvoiceDate FROM CUSTOMER JOIN INVOICE ON CUSTOMER.CustomerId = INVOICE.CustomerId WHERE CUSTOMER.FirstName = "Astrid" AND LastName = "Gruber"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'lastname'], 'invoice': ['invoiceid', 'customerid', 'invoicedate'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
Find all the customer last names that do not have invoice totals larger than 20.
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT LastName FROM CUSTOMER EXCEPT SELECT CUSTOMER.LastName FROM CUSTOMER JOIN Invoice ON CUSTOMER.CustomerId = Invoice.CustomerId WHERE Invoice.total > 20
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'lastname'], 'invoice': ['invoiceid', 'customerid', 'total'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.LastName (varchar(20)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.Total (decimal(10,2)), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
What are the last names of customers without invoice totals exceeding 20?
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT LastName FROM CUSTOMER EXCEPT SELECT CUSTOMER.LastName FROM CUSTOMER JOIN Invoice ON CUSTOMER.CustomerId = Invoice.CustomerId WHERE Invoice.total > 20
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'lastname'], 'invoice': ['invoiceid', 'customerid', 'total'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.LastName (varchar(20)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.Total (decimal(10,2)), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
Find the first names of all customers that live in Brazil and have an invoice.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT DISTINCT CUSTOMER.FirstName FROM CUSTOMER JOIN INVOICE ON CUSTOMER.CustomerId = INVOICE.CustomerId WHERE CUSTOMER.country = "Brazil"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'country'], 'invoice': ['invoiceid', 'customerid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.Country (varchar(40)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
What are the different first names for customers from Brazil who have also had an invoice?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT DISTINCT CUSTOMER.FirstName FROM CUSTOMER JOIN INVOICE ON CUSTOMER.CustomerId = INVOICE.CustomerId WHERE CUSTOMER.country = "Brazil"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'country'], 'invoice': ['invoiceid', 'customerid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.Country (varchar(40)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
Find the address of all customers that live in Germany and have invoice.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT DISTINCT CUSTOMER.Address FROM CUSTOMER JOIN INVOICE ON CUSTOMER.CustomerId = INVOICE.CustomerId WHERE CUSTOMER.country = "Germany"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'address', 'country'], 'invoice': ['invoiceid', 'customerid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.Address (varchar(70)), Customer.Country (varchar(40)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
What are the addresses of customers living in Germany who have had an invoice?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT DISTINCT CUSTOMER.Address FROM CUSTOMER JOIN INVOICE ON CUSTOMER.CustomerId = INVOICE.CustomerId WHERE CUSTOMER.country = "Germany"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'address', 'country'], 'invoice': ['invoiceid', 'customerid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.Address (varchar(70)), Customer.Country (varchar(40)), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId
chinook_1
List the phone numbers of all employees.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Phone FROM EMPLOYEE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'phone'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.Phone (varchar(24)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
What are the phone numbers for each employee?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Phone FROM EMPLOYEE
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'phone'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.Phone (varchar(24)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
How many tracks are in the AAC audio file media type?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM MEDIATYPE JOIN TRACK ON MEDIATYPE.MediaTypeId = TRACK.MediaTypeId WHERE MEDIATYPE.Name = "AAC audio file"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'mediatype': ['mediatypeid', 'name'], 'track': ['trackid', 'mediatypeid'] }
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.MediaTypeId (INTEGER), )
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Count the number of tracks that are of the media type "AAC audio file".
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT COUNT(*) FROM MEDIATYPE JOIN TRACK ON MEDIATYPE.MediaTypeId = TRACK.MediaTypeId WHERE MEDIATYPE.Name = "AAC audio file"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'mediatype': ['mediatypeid', 'name'], 'track': ['trackid', 'mediatypeid'] }
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.MediaTypeId (INTEGER), )
TABLE MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What is the average duration in milliseconds of tracks that belong to Latin or Pop genre?
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(Milliseconds) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Latin" OR GENRE.Name = "Pop"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'milliseconds'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.Milliseconds (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the average millisecond length of Latin and Pop tracks.
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(Milliseconds) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Latin" OR GENRE.Name = "Pop"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'milliseconds'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.Milliseconds (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Please show the employee first names and ids of employees who serve at least 10 customers.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT CUSTOMER.FirstName , CUSTOMER.SupportRepId FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId GROUP BY CUSTOMER.SupportRepId HAVING COUNT(*) >= 10
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'supportrepid'], 'employee': ['employeeid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
What are the first names and support rep ids for employees serving 10 or more customers?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT CUSTOMER.FirstName , CUSTOMER.SupportRepId FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId GROUP BY CUSTOMER.SupportRepId HAVING COUNT(*) >= 10
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'firstname', 'supportrepid'], 'employee': ['employeeid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
Please show the employee last names that serves no more than 20 customers.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT CUSTOMER.LastName FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId GROUP BY CUSTOMER.SupportRepId HAVING COUNT(*) <= 20
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'lastname', 'supportrepid'], 'employee': ['employeeid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.LastName (varchar(20)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
What are the last names of employees who serve at most 20 customers?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT CUSTOMER.LastName FROM CUSTOMER JOIN EMPLOYEE ON CUSTOMER.SupportRepId = EMPLOYEE.EmployeeId GROUP BY CUSTOMER.SupportRepId HAVING COUNT(*) <= 20
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'customer': ['customerid', 'lastname', 'supportrepid'], 'employee': ['employeeid'] }
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.LastName (varchar(20)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), ) Possible JOINs:
TABLE Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId
chinook_1
Please list all album titles in alphabetical order.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Title FROM ALBUM ORDER BY Title
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What are all the album titles, in alphabetical order?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Title FROM ALBUM ORDER BY Title
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Please list the name and id of all artists that have at least 3 albums in alphabetical order.
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ARTIST.Name , ALBUM.ArtistId FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistID GROUP BY ALBUM.ArtistId HAVING COUNT(*) >= 3 ORDER BY ARTIST.Name
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What are the names and ids of artists with 3 or more albums, listed in alphabetical order?
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT ARTIST.Name , ALBUM.ArtistId FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistID GROUP BY ALBUM.ArtistId HAVING COUNT(*) >= 3 ORDER BY ARTIST.Name
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'artistid'], 'artist': ['artistid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Find the names of artists that do not have any albums.
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM ARTIST EXCEPT SELECT ARTIST.Name FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'artist': ['artistid', 'name'], 'album': ['albumid', 'artistid'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What are the names of artists who have not released any albums?
hard
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Name FROM ARTIST EXCEPT SELECT ARTIST.Name FROM ALBUM JOIN ARTIST ON ALBUM.ArtistId = ARTIST.ArtistId
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'artist': ['artistid', 'name'], 'album': ['albumid', 'artistid'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What is the average unit price of rock tracks?
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(TRACK.UnitPrice) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Rock"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'unitprice'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the average unit price of tracks from the Rock genre.
medium
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT AVG(TRACK.UnitPrice) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Rock"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'unitprice'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What are the duration of the longest and shortest pop tracks in milliseconds?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Pop"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'milliseconds'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.Milliseconds (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the maximum and minimum millisecond lengths of pop tracks.
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE JOIN TRACK ON GENRE.GenreId = TRACK.GenreId WHERE GENRE.Name = "Pop"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'genre': ['genreid', 'name'], 'track': ['trackid', 'genreid', 'milliseconds'] }
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.GenreId (INTEGER), Track.Milliseconds (INTEGER), )
TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
What are the birth dates of employees living in Edmonton?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT BirthDate FROM EMPLOYEE WHERE City = "Edmonton"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'birthdate', 'city'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.BirthDate (datetime), Employee.City (varchar(40)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
Find the birth dates corresponding to employees who live in the city of Edmonton.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT BirthDate FROM EMPLOYEE WHERE City = "Edmonton"
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'employee': ['employeeid', 'birthdate', 'city'] }
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.BirthDate (datetime), Employee.City (varchar(40)), )
TABLE Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Possible JOINs: Employee.ReportsTo = Employee.EmployeeId
chinook_1
What are the distinct unit prices of all tracks?
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT distinct(UnitPrice) FROM TRACK
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'unitprice'] }
TABLE Track ( Track.TrackId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the distinct unit prices for tracks.
easy
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT distinct(UnitPrice) FROM TRACK
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'track': ['trackid', 'unitprice'] }
TABLE Track ( Track.TrackId (INTEGER), Track.UnitPrice (decimal(10,2)), )
TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
How many artists do not have any album?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM)
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'artist': ['artistid'], 'album': ['albumid', 'artistid'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
Cound the number of artists who have not released an album.
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM)
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'artist': ['artistid'], 'album': ['albumid', 'artistid'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), )
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId
chinook_1
What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks?
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Album.Title FROM Album JOIN Track ON Album.AlbumId = Track.AlbumId JOIN Genre ON Track.GenreID = Genre.GenreID WHERE Genre.Name = 'Reggae' INTERSECT SELECT Album.Title FROM Album JOIN Track ON Album.AlbumId = Track.AlbumId JOIN Genre ON Track.GenreID = Genre.GenreID WHERE Genre.Name = 'Rock'
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'], 'track': ['trackid', 'albumid', 'genreid'], 'genre': ['genreid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), ) TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.AlbumId (INTEGER), Track.GenreId (INTEGER), ) Possible JOINs:
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
chinook_1
Find the titles of albums that contain tracks of both the Reggae and Rock genres.
extra
Table Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) Table Artist ( Artist.ArtistId (INTEGER), Artist.Name (varchar(120)), ) Table Customer ( Customer.CustomerId (INTEGER), Customer.FirstName (varchar(40)), Customer.LastName (varchar(20)), Customer.Company (varchar(80)), Customer.Address (varchar(70)), Customer.City (varchar(40)), Customer.State (varchar(40)), Customer.Country (varchar(40)), Customer.PostalCode (varchar(10)), Customer.Phone (varchar(24)), Customer.Fax (varchar(24)), Customer.Email (varchar(60)), Customer.SupportRepId (INTEGER), ) Table Employee ( Employee.EmployeeId (INTEGER), Employee.LastName (varchar(20)), Employee.FirstName (varchar(20)), Employee.Title (varchar(30)), Employee.ReportsTo (INTEGER), Employee.BirthDate (datetime), Employee.HireDate (datetime), Employee.Address (varchar(70)), Employee.City (varchar(40)), Employee.State (varchar(40)), Employee.Country (varchar(40)), Employee.PostalCode (varchar(10)), Employee.Phone (varchar(24)), Employee.Fax (varchar(24)), Employee.Email (varchar(60)), ) Table Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) Table Invoice ( Invoice.InvoiceId (INTEGER), Invoice.CustomerId (INTEGER), Invoice.InvoiceDate (datetime), Invoice.BillingAddress (varchar(70)), Invoice.BillingCity (varchar(40)), Invoice.BillingState (varchar(40)), Invoice.BillingCountry (varchar(40)), Invoice.BillingPostalCode (varchar(10)), Invoice.Total (decimal(10,2)), ) Table InvoiceLine ( InvoiceLine.InvoiceLineId (INTEGER), InvoiceLine.InvoiceId (INTEGER), InvoiceLine.TrackId (INTEGER), InvoiceLine.UnitPrice (decimal(10,2)), InvoiceLine.Quantity (INTEGER), ) Table MediaType ( MediaType.MediaTypeId (INTEGER), MediaType.Name (varchar(120)), ) Table Playlist ( Playlist.PlaylistId (INTEGER), Playlist.Name (varchar(120)), ) Table PlaylistTrack ( PlaylistTrack.PlaylistId (INTEGER), PlaylistTrack.TrackId (INTEGER), ) Table Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Customer.SupportRepId = Employee.EmployeeId Employee.ReportsTo = Employee.EmployeeId Invoice.CustomerId = Customer.CustomerId InvoiceLine.InvoiceId = Invoice.InvoiceId InvoiceLine.TrackId = Track.TrackId PlaylistTrack.PlaylistId = Playlist.PlaylistId PlaylistTrack.TrackId = Track.TrackId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
SELECT Album.Title FROM Album JOIN Track ON Album.AlbumId = Track.AlbumId JOIN Genre ON Track.GenreID = Genre.GenreID WHERE Genre.Name = 'Reggae' INTERSECT SELECT Album.Title FROM Album JOIN Track ON Album.AlbumId = Track.AlbumId JOIN Genre ON Track.GenreID = Genre.GenreID WHERE Genre.Name = 'Rock'
Table album ( album.albumid (INTEGER), album.title (varchar(160)), album.artistid (INTEGER), ) Table artist ( artist.artistid (INTEGER), artist.name (varchar(120)), ) Table customer ( customer.customerid (INTEGER), customer.firstname (varchar(40)), customer.lastname (varchar(20)), customer.company (varchar(80)), customer.address (varchar(70)), customer.city (varchar(40)), customer.state (varchar(40)), customer.country (varchar(40)), customer.postalcode (varchar(10)), customer.phone (varchar(24)), customer.fax (varchar(24)), customer.email (varchar(60)), customer.supportrepid (INTEGER), ) Table employee ( employee.employeeid (INTEGER), employee.lastname (varchar(20)), employee.firstname (varchar(20)), employee.title (varchar(30)), employee.reportsto (INTEGER), employee.birthdate (datetime), employee.hiredate (datetime), employee.address (varchar(70)), employee.city (varchar(40)), employee.state (varchar(40)), employee.country (varchar(40)), employee.postalcode (varchar(10)), employee.phone (varchar(24)), employee.fax (varchar(24)), employee.email (varchar(60)), ) Table genre ( genre.genreid (INTEGER), genre.name (varchar(120)), ) Table invoice ( invoice.invoiceid (INTEGER), invoice.customerid (INTEGER), invoice.invoicedate (datetime), invoice.billingaddress (varchar(70)), invoice.billingcity (varchar(40)), invoice.billingstate (varchar(40)), invoice.billingcountry (varchar(40)), invoice.billingpostalcode (varchar(10)), invoice.total (decimal(10,2)), ) Table invoiceline ( invoiceline.invoicelineid (INTEGER), invoiceline.invoiceid (INTEGER), invoiceline.trackid (INTEGER), invoiceline.unitprice (decimal(10,2)), invoiceline.quantity (INTEGER), ) Table mediatype ( mediatype.mediatypeid (INTEGER), mediatype.name (varchar(120)), ) Table playlist ( playlist.playlistid (INTEGER), playlist.name (varchar(120)), ) Table playlisttrack ( playlisttrack.playlistid (INTEGER), playlisttrack.trackid (INTEGER), ) Table track ( track.trackid (INTEGER), track.name (varchar(200)), track.albumid (INTEGER), track.mediatypeid (INTEGER), track.genreid (INTEGER), track.composer (varchar(220)), track.milliseconds (INTEGER), track.bytes (INTEGER), track.unitprice (decimal(10,2)), ) Possible JOINs: album.artistid = artist.artistid customer.supportrepid = employee.employeeid employee.reportsto = employee.employeeid invoice.customerid = customer.customerid invoiceline.invoiceid = invoice.invoiceid invoiceline.trackid = track.trackid playlisttrack.playlistid = playlist.playlistid playlisttrack.trackid = track.trackid track.albumid = album.albumid track.mediatypeid = mediatype.mediatypeid track.genreid = genre.genreid
{ 'album': ['albumid', 'title', 'artistid'], 'artist': ['artistid', 'name'], 'customer': ['customerid', 'firstname', 'lastname', 'company', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email', 'supportrepid'], 'employee': ['employeeid', 'lastname', 'firstname', 'title', 'reportsto', 'birthdate', 'hiredate', 'address', 'city', 'state', 'country', 'postalcode', 'phone', 'fax', 'email'], 'genre': ['genreid', 'name'], 'invoice': ['invoiceid', 'customerid', 'invoicedate', 'billingaddress', 'billingcity', 'billingstate', 'billingcountry', 'billingpostalcode', 'total'], 'invoiceline': ['invoicelineid', 'invoiceid', 'trackid', 'unitprice', 'quantity'], 'mediatype': ['mediatypeid', 'name'], 'playlist': ['playlistid', 'name'], 'playlisttrack': ['playlistid', 'trackid'], 'track': ['trackid', 'name', 'albumid', 'mediatypeid', 'genreid', 'composer', 'milliseconds', 'bytes', 'unitprice'] }
{ 'album': ['albumid', 'title'], 'track': ['trackid', 'albumid', 'genreid'], 'genre': ['genreid', 'name'] }
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), ) TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.AlbumId (INTEGER), Track.GenreId (INTEGER), ) Possible JOINs:
TABLE Album ( Album.AlbumId (INTEGER), Album.Title (varchar(160)), Album.ArtistId (INTEGER), ) TABLE Genre ( Genre.GenreId (INTEGER), Genre.Name (varchar(120)), ) TABLE Track ( Track.TrackId (INTEGER), Track.Name (varchar(200)), Track.AlbumId (INTEGER), Track.MediaTypeId (INTEGER), Track.GenreId (INTEGER), Track.Composer (varchar(220)), Track.Milliseconds (INTEGER), Track.Bytes (INTEGER), Track.UnitPrice (decimal(10,2)), ) Possible JOINs: Album.ArtistId = Artist.ArtistId Track.AlbumId = Album.AlbumId Track.MediaTypeId = MediaType.MediaTypeId Track.GenreId = Genre.GenreId
insurance_fnol
Find all the phone numbers.
easy
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT customer_phone FROM available_policies
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'customer_phone'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
What are all the phone numbers?
easy
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT customer_phone FROM available_policies
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'customer_phone'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
What are the customer phone numbers under the policy "Life Insurance"?
easy
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT customer_phone FROM available_policies WHERE policy_type_code = "Life Insurance"
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
What are the phone numbers of customers using the policy with the code "Life Insurance"?
easy
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT customer_phone FROM available_policies WHERE policy_type_code = "Life Insurance"
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
Which policy type has the most records in the database?
hard
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
Which policy type appears most frequently in the available policies?
hard
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
What are all the customer phone numbers under the most popular policy type?
hard
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT customer_phone FROM available_policies WHERE policy_type_code = (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1)
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
Find the phone numbers of customers using the most common policy type among the available policies.
hard
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT customer_phone FROM available_policies WHERE policy_type_code = (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1)
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs:
insurance_fnol
Find the policy type used by more than 4 customers.
easy
Table Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Table Claims ( Claims.Claim_ID (INTEGER), Claims.FNOL_ID (INTEGER), Claims.Effective_Date (DATE), ) Table Customers ( Customers.Customer_ID (INTEGER), Customers.Customer_name (VARCHAR(40)), ) Table Customers_Policies ( Customers_Policies.Customer_ID (INTEGER), Customers_Policies.Policy_ID (INTEGER), Customers_Policies.Date_Opened (DATE), Customers_Policies.Date_Closed (DATE), ) Table First_Notification_of_Loss ( First_Notification_of_Loss.FNOL_ID (INTEGER), First_Notification_of_Loss.Customer_ID (INTEGER), First_Notification_of_Loss.Policy_ID (INTEGER), First_Notification_of_Loss.Service_ID (INTEGER), ) Table Services ( Services.Service_ID (INTEGER), Services.Service_name (VARCHAR(40)), ) Table Settlements ( Settlements.Settlement_ID (INTEGER), Settlements.Claim_ID (INTEGER), Settlements.Effective_Date (DATE), Settlements.Settlement_Amount (REAL), ) Possible JOINs: Claims.FNOL_ID = First_Notification_of_Loss.FNOL_ID Customers_Policies.Customer_ID = Customers.Customer_ID Customers_Policies.Policy_ID = Available_Policies.Policy_ID First_Notification_of_Loss.Customer_ID = Customers_Policies.Customer_ID First_Notification_of_Loss.Policy_ID = Customers_Policies.Policy_ID First_Notification_of_Loss.Service_ID = Services.Service_ID Settlements.Claim_ID = Claims.Claim_ID
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*) > 4
Table available_policies ( available_policies.policy_id (INTEGER), available_policies.policy_type_code (CHAR(15)), available_policies.customer_phone (VARCHAR(255)), ) Table claims ( claims.claim_id (INTEGER), claims.fnol_id (INTEGER), claims.effective_date (DATE), ) Table customers ( customers.customer_id (INTEGER), customers.customer_name (VARCHAR(40)), ) Table customers_policies ( customers_policies.customer_id (INTEGER), customers_policies.policy_id (INTEGER), customers_policies.date_opened (DATE), customers_policies.date_closed (DATE), ) Table first_notification_of_loss ( first_notification_of_loss.fnol_id (INTEGER), first_notification_of_loss.customer_id (INTEGER), first_notification_of_loss.policy_id (INTEGER), first_notification_of_loss.service_id (INTEGER), ) Table services ( services.service_id (INTEGER), services.service_name (VARCHAR(40)), ) Table settlements ( settlements.settlement_id (INTEGER), settlements.claim_id (INTEGER), settlements.effective_date (DATE), settlements.settlement_amount (REAL), ) Possible JOINs: claims.fnol_id = first_notification_of_loss.fnol_id customers_policies.customer_id = customers.customer_id customers_policies.policy_id = available_policies.policy_id first_notification_of_loss.customer_id = customers_policies.customer_id first_notification_of_loss.policy_id = customers_policies.policy_id first_notification_of_loss.service_id = services.service_id settlements.claim_id = claims.claim_id
{ 'customers': ['customer_id', 'customer_name'], 'services': ['service_id', 'service_name'], 'available_policies': ['policy_id', 'policy_type_code', 'customer_phone'], 'customers_policies': ['customer_id', 'policy_id', 'date_opened', 'date_closed'], 'first_notification_of_loss': ['fnol_id', 'customer_id', 'policy_id', 'service_id'], 'claims': ['claim_id', 'fnol_id', 'effective_date'], 'settlements': ['settlement_id', 'claim_id', 'effective_date', 'settlement_amount'] }
{ 'available_policies': ['policy_id', 'policy_type_code'] }
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), ) Possible JOINs:
TABLE Available_Policies ( Available_Policies.Policy_ID (INTEGER), Available_Policies.policy_type_code (CHAR(15)), Available_Policies.Customer_Phone (VARCHAR(255)), ) Possible JOINs: