SQL
stringlengths 18
577
| question
stringlengths 317
11.5k
|
---|---|
SELECT avg(num_of_staff) , avg(score) FROM shop | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. What are the average score and average staff number of all shops? |
SELECT shop_id , address FROM shop WHERE score < (SELECT avg(score) FROM shop) | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Find the id and address of the shops whose score is below the average score. |
SELECT address , num_of_staff FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM happy_hour) | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Find the address and staff number of the shops that do not have any happy hour. |
SELECT t1.address , t1.shop_id FROM shop AS t1 JOIN happy_hour AS t2 ON t1.shop_id = t2.shop_id WHERE MONTH = 'May' | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. What are the id and address of the shops which have a happy hour in May? |
SELECT shop_id , count(*) FROM happy_hour GROUP BY shop_id ORDER BY count(*) DESC LIMIT 1 | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. which shop has happy hour most frequently? List its id and number of happy hours. |
SELECT MONTH FROM happy_hour GROUP BY MONTH ORDER BY count(*) DESC LIMIT 1 | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Which month has the most happy hours? |
SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING count(*) > 2 | Given the Table shop having columns as Shop_ID has datatype number, Address has datatype text, Num_of_staff has datatype text, Score has datatype number, Open_Year has datatype text which has Shop_ID and Given the Table member having columns as Member_ID has datatype number, Name has datatype text, Membership_card has datatype text, Age has datatype number, Time_of_purchase has datatype number, Level_of_membership has datatype number, Address has datatype text which has Member_ID and Given the Table happy hour having columns as HH_ID has datatype number, Shop_ID has datatype number, Month has datatype text, Num_of_shaff_in_charge has datatype number which has HH_ID and Given the Table happy hour member having columns as HH_ID has datatype number, Member_ID has datatype number, Total_amount has datatype number which has HH_ID. Answer the question by writing the appropriate SQL code. Which months have more than 2 happy hours? |
SELECT count(*) FROM ALBUM | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. How many albums are there? |
SELECT count(*) FROM ALBUM | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the number of albums. |
SELECT Name FROM GENRE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. List the names of all music genres. |
SELECT Name FROM GENRE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the names of different music genres? |
SELECT * FROM CUSTOMER WHERE State = "NY" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find all the customer information in state NY. |
SELECT * FROM CUSTOMER WHERE State = "NY" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is all the customer information for customers in NY state? |
SELECT FirstName , LastName FROM EMPLOYEE WHERE City = "Calgary" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the first names and last names of the employees who live in Calgary city. |
SELECT FirstName , LastName FROM EMPLOYEE WHERE City = "Calgary" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the full names of employees living in the city of Calgary. |
SELECT distinct(BillingCountry) FROM INVOICE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the distinct billing countries of the invoices? |
SELECT distinct(BillingCountry) FROM INVOICE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the different billing countries for all invoices. |
SELECT Name FROM ARTIST WHERE Name LIKE "%a%" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the names of all artists that have "a" in their names. |
SELECT Name FROM ARTIST WHERE Name LIKE "%a%" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the names of artist who have the letter 'a' in their names? |
SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "AC/DC" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the title of all the albums of the artist "AC/DC". |
SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "AC/DC" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the titles of albums by the artist "AC/DC"? |
SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "Metallica" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Hom many albums does the artist "Metallica" have? |
SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "Metallica" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the number of albums by the artist "Metallica". |
SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = "Balls to the Wall" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Which artist does the album "Balls to the Wall" belong to? |
SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = "Balls to the Wall" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the name of the artist who made the album "Balls to the Wall". |
SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId GROUP BY T2.Name ORDER BY COUNT(*) DESC LIMIT 1 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Which artist has the most albums? |
SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId GROUP BY T2.Name ORDER BY COUNT(*) DESC LIMIT 1 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the name of the artist with the greatest number of albums? |
SELECT Name FROM TRACK WHERE Name LIKE '%you%' | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the names of all the tracks that contain the word "you". |
SELECT Name FROM TRACK WHERE Name LIKE '%you%' | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the names of tracks that contain the the word you in them? |
SELECT AVG(UnitPrice) FROM TRACK | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the average unit price of all the tracks? |
SELECT AVG(UnitPrice) FROM TRACK | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the average unit price for a track. |
SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the durations of the longest and the shortest tracks in milliseconds? |
SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the maximum and minimum durations of tracks in milliseconds. |
SELECT T1.Title , T2.AlbumID , COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Show the album names, ids and the number of tracks for each album. |
SELECT T1.Title , T2.AlbumID , COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the names and ids of the different albums, and how many tracks are on each? |
SELECT T1.Name FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId GROUP BY T2.GenreId ORDER BY COUNT(*) DESC LIMIT 1 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the name of the most common genre in all tracks? |
SELECT T1.Name FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId GROUP BY T2.GenreId ORDER BY COUNT(*) DESC LIMIT 1 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the name of the genre that is most frequent across all tracks. |
SELECT T1.Name FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.MediaTypeId ORDER BY COUNT(*) ASC LIMIT 1 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the least common media type in all tracks? |
SELECT T1.Name FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.MediaTypeId ORDER BY COUNT(*) ASC LIMIT 1 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the name of the media type that is least common across all tracks? |
SELECT T1.Title , T2.AlbumID FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId WHERE T2.UnitPrice > 1 GROUP BY T2.AlbumID | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Show the album names and ids for albums that contain tracks with unit price bigger than 1. |
SELECT T1.Title , T2.AlbumID FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId WHERE T2.UnitPrice > 1 GROUP BY T2.AlbumID | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the titles and ids for albums containing tracks with unit price greater than 1? |
SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. How many tracks belong to rock genre? |
SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Count the number of tracks that are part of the rock genre. |
SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Jazz" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the average unit price of tracks that belong to Jazz genre? |
SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Jazz" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the average unit price of jazz tracks. |
SELECT FirstName , LastName FROM CUSTOMER WHERE Email = "[email protected]" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the first name and last name of the customer that has email "[email protected]"? |
SELECT FirstName , LastName FROM CUSTOMER WHERE Email = "[email protected]" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the full name of the customer with the email "[email protected]". |
SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. How many customers have email that contains "gmail.com"? |
SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Count the number of customers that have an email containing "gmail.com". |
SELECT T2.FirstName , T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = "Leonie" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the first name and last name employee helps the customer with first name Leonie? |
SELECT T2.FirstName , T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = "Leonie" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the full names of employees who help customers with the first name Leonie. |
SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = "70174" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What city does the employee who helps the customer with postal code 70174 live in? |
SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = "70174" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the cities corresponding to employees who help customers with the postal code 70174. |
SELECT COUNT(DISTINCT city) FROM EMPLOYEE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. How many distinct cities does the employees live in? |
SELECT COUNT(DISTINCT city) FROM EMPLOYEE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the number of different cities that employees live in. |
SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = "Astrid" AND LastName = "Gruber" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find all invoice dates corresponding to customers with first name Astrid and last name Gruber. |
SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = "Astrid" AND LastName = "Gruber" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the invoice dates for customers with the first name Astrid and the last name Gruber? |
SELECT LastName FROM CUSTOMER EXCEPT SELECT T1.LastName FROM CUSTOMER AS T1 JOIN Invoice AS T2 ON T1.CustomerId = T2.CustomerId WHERE T2.total > 20 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find all the customer last names that do not have invoice totals larger than 20. |
SELECT LastName FROM CUSTOMER EXCEPT SELECT T1.LastName FROM CUSTOMER AS T1 JOIN Invoice AS T2 ON T1.CustomerId = T2.CustomerId WHERE T2.total > 20 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the last names of customers without invoice totals exceeding 20? |
SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Brazil" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the first names of all customers that live in Brazil and have an invoice. |
SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Brazil" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the different first names for customers from Brazil who have also had an invoice? |
SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Germany" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the address of all customers that live in Germany and have invoice. |
SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Germany" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the addresses of customers living in Germany who have had an invoice? |
SELECT Phone FROM EMPLOYEE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. List the phone numbers of all employees. |
SELECT Phone FROM EMPLOYEE | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the phone numbers for each employee? |
SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = "AAC audio file" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. How many tracks are in the AAC audio file media type? |
SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = "AAC audio file" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Count the number of tracks that are of the media type "AAC audio file". |
SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Latin" OR T1.Name = "Pop" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the average duration in milliseconds of tracks that belong to Latin or Pop genre? |
SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Latin" OR T1.Name = "Pop" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the average millisecond length of Latin and Pop tracks. |
SELECT T1.FirstName , T1.SupportRepId FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) >= 10 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Please show the employee first names and ids of employees who serve at least 10 customers. |
SELECT T1.FirstName , T1.SupportRepId FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) >= 10 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the first names and support rep ids for employees serving 10 or more customers? |
SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Please show the employee last names that serves no more than 20 customers. |
SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20 | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the last names of employees who serve at most 20 customers? |
SELECT Title FROM ALBUM ORDER BY Title | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Please list all album titles in alphabetical order. |
SELECT Title FROM ALBUM ORDER BY Title | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are all the album titles, in alphabetical order? |
SELECT T2.Name , T1.ArtistId FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistID GROUP BY T1.ArtistId HAVING COUNT(*) >= 3 ORDER BY T2.Name | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Please list the name and id of all artists that have at least 3 albums in alphabetical order. |
SELECT T2.Name , T1.ArtistId FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistID GROUP BY T1.ArtistId HAVING COUNT(*) >= 3 ORDER BY T2.Name | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the names and ids of artists with 3 or more albums, listed in alphabetical order? |
SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the names of artists that do not have any albums. |
SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the names of artists who have not released any albums? |
SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What is the average unit price of rock tracks? |
SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the average unit price of tracks from the Rock genre. |
SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Pop" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the duration of the longest and shortest pop tracks in milliseconds? |
SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Pop" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the maximum and minimum millisecond lengths of pop tracks. |
SELECT BirthDate FROM EMPLOYEE WHERE City = "Edmonton" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the birth dates of employees living in Edmonton? |
SELECT BirthDate FROM EMPLOYEE WHERE City = "Edmonton" | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the birth dates corresponding to employees who live in the city of Edmonton. |
SELECT distinct(UnitPrice) FROM TRACK | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the distinct unit prices of all tracks? |
SELECT distinct(UnitPrice) FROM TRACK | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the distinct unit prices for tracks. |
SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM) | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. How many artists do not have any album? |
SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM) | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Cound the number of artists who have not released an album. |
SELECT T1.Title FROM Album AS T1 JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId JOIN Genre AS T3 ON T2.GenreID = T3.GenreID WHERE T3.Name = 'Reggae' INTERSECT SELECT T1.Title FROM Album AS T1 JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId JOIN Genre AS T3 ON T2.GenreID = T3.GenreID WHERE T3.Name = 'Rock' | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks? |
SELECT T1.Title FROM Album AS T1 JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId JOIN Genre AS T3 ON T2.GenreID = T3.GenreID WHERE T3.Name = 'Reggae' INTERSECT SELECT T1.Title FROM Album AS T1 JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId JOIN Genre AS T3 ON T2.GenreID = T3.GenreID WHERE T3.Name = 'Rock' | Given the Table album having columns as AlbumId has datatype number, Title has datatype text, ArtistId has datatype number which has AlbumId and Given the Table artist having columns as ArtistId has datatype number, Name has datatype text which has ArtistId and Given the Table customer having columns as CustomerId has datatype number, FirstName has datatype text, LastName has datatype text, Company has datatype text, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text, SupportRepId has datatype number which has CustomerId and Given the Table employee having columns as EmployeeId has datatype number, LastName has datatype text, FirstName has datatype text, Title has datatype text, ReportsTo has datatype number, BirthDate has datatype time, HireDate has datatype time, Address has datatype text, City has datatype text, State has datatype text, Country has datatype text, PostalCode has datatype text, Phone has datatype text, Fax has datatype text, Email has datatype text which has EmployeeId and Given the Table genre having columns as GenreId has datatype number, Name has datatype text which has GenreId and Given the Table invoice having columns as InvoiceId has datatype number, CustomerId has datatype number, InvoiceDate has datatype time, BillingAddress has datatype text, BillingCity has datatype text, BillingState has datatype text, BillingCountry has datatype text, BillingPostalCode has datatype text, Total has datatype number which has InvoiceId and Given the Table invoice line having columns as InvoiceLineId has datatype number, InvoiceId has datatype number, TrackId has datatype number, UnitPrice has datatype number, Quantity has datatype number which has InvoiceLineId and Given the Table media type having columns as MediaTypeId has datatype number, Name has datatype text which has MediaTypeId and Given the Table playlist having columns as PlaylistId has datatype number, Name has datatype text which has PlaylistId and Given the Table playlist track having columns as PlaylistId has datatype number, TrackId has datatype number which has PlaylistId and Given the Table track having columns as TrackId has datatype number, Name has datatype text, AlbumId has datatype number, MediaTypeId has datatype number, GenreId has datatype number, Composer has datatype text, Milliseconds has datatype number, Bytes has datatype number, UnitPrice has datatype number which has TrackId. Answer the question by writing the appropriate SQL code. Find the titles of albums that contain tracks of both the Reggae and Rock genres. |
SELECT customer_phone FROM available_policies | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. Find all the phone numbers. |
SELECT customer_phone FROM available_policies | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. What are all the phone numbers? |
SELECT customer_phone FROM available_policies WHERE policy_type_code = "Life Insurance" | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. What are the customer phone numbers under the policy "Life Insurance"? |
SELECT customer_phone FROM available_policies WHERE policy_type_code = "Life Insurance" | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. What are the phone numbers of customers using the policy with the code "Life Insurance"? |
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1 | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. Which policy type has the most records in the database? |
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1 | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. Which policy type appears most frequently in the available policies? |
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) | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. What are all the customer phone numbers under the most popular policy type? |
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) | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. Find the phone numbers of customers using the most common policy type among the available policies. |
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*) > 4 | Given the Table customers having columns as Customer_ID has datatype number, Customer_name has datatype text which has Customer_ID and Given the Table services having columns as Service_ID has datatype number, Service_name has datatype text which has Service_ID and Given the Table available policies having columns as Policy_ID has datatype number, policy_type_code has datatype text, Customer_Phone has datatype text which has Policy_ID and Given the Table customers policies having columns as Customer_ID has datatype number, Policy_ID has datatype number, Date_Opened has datatype time, Date_Closed has datatype time which has Customer_ID and Given the Table first notification of loss having columns as FNOL_ID has datatype number, Customer_ID has datatype number, Policy_ID has datatype number, Service_ID has datatype number which has FNOL_ID and Given the Table claims having columns as Claim_ID has datatype number, FNOL_ID has datatype number, Effective_Date has datatype time which has Claim_ID and Given the Table settlements having columns as Settlement_ID has datatype number, Claim_ID has datatype number, Effective_Date has datatype time, Settlement_Amount has datatype number which has Settlement_ID. Answer the question by writing the appropriate SQL code. Find the policy type used by more than 4 customers. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.