db_id
stringclasses
140 values
messages
listlengths
2
2
coffee_shop
[ { "content": "Translate the following question to SQL: What are the average score and average staff number of all shops?\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT avg(num_of_staff) , avg(score) FROM shop", "role": "assistant" } ]
coffee_shop
[ { "content": "Translate the following question to SQL: Find the id and address of the shops whose score is below the average score.\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT shop_id , address FROM shop WHERE score < (SELECT avg(score) FROM shop)", "role": "assistant" } ]
coffee_shop
[ { "content": "Translate the following question to SQL: Find the address and staff number of the shops that do not have any happy hour.\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT address , num_of_staff FROM shop WHERE shop_id NOT IN (SELECT shop_id FROM happy_hour)", "role": "assistant" } ]
coffee_shop
[ { "content": "Translate the following question to SQL: What are the id and address of the shops which have a happy hour in May?\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "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'", "role": "assistant" } ]
coffee_shop
[ { "content": "Translate the following question to SQL: which shop has happy hour most frequently? List its id and number of happy hours.\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT shop_id , count(*) FROM happy_hour GROUP BY shop_id ORDER BY count(*) DESC LIMIT 1", "role": "assistant" } ]
coffee_shop
[ { "content": "Translate the following question to SQL: Which month has the most happy hours?\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT MONTH FROM happy_hour GROUP BY MONTH ORDER BY count(*) DESC LIMIT 1", "role": "assistant" } ]
coffee_shop
[ { "content": "Translate the following question to SQL: Which months have more than 2 happy hours?\n\nSchema: CREATE TABLE shop (\n Shop_ID INT PRIMARY KEY,\n Address TEXT,\n Num_of_staff TEXT,\n Score REAL,\n Open_Year TEXT,\n UNIQUE (Shop_ID)\n);\n\nCREATE TABLE member (\n Member_ID INT PRIMARY KEY,\n Name TEXT,\n Membership_card TEXT,\n Age INT,\n Time_of_purchase INT,\n Level_of_membership INT,\n Address TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE happy_hour (\n HH_ID INT PRIMARY KEY,\n Shop_ID INT PRIMARY KEY,\n Month TEXT PRIMARY KEY,\n Num_of_shaff_in_charge INT,\n PRIMARY KEY (HH_ID, Shop_ID, Month),\n UNIQUE (HH_ID, Shop_ID, Month),\n FOREIGN KEY (Shop_ID) REFERENCES shop(Shop_ID)\n);\n\nCREATE TABLE happy_hour_member (\n HH_ID INT PRIMARY KEY,\n Member_ID INT PRIMARY KEY,\n Total_amount REAL,\n PRIMARY KEY (HH_ID, Member_ID),\n UNIQUE (HH_ID, Member_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING count(*) > 2", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: How many albums are there?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT count(*) FROM ALBUM", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the number of albums.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT count(*) FROM ALBUM", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: List the names of all music genres.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM GENRE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the names of different music genres?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM GENRE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find all the customer information in state NY.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT * FROM CUSTOMER WHERE State = \"NY\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is all the customer information for customers in NY state?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT * FROM CUSTOMER WHERE State = \"NY\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the first names and last names of the employees who live in Calgary city.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT FirstName , LastName FROM EMPLOYEE WHERE City = \"Calgary\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the full names of employees living in the city of Calgary.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT FirstName , LastName FROM EMPLOYEE WHERE City = \"Calgary\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the distinct billing countries of the invoices?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT distinct(BillingCountry) FROM INVOICE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the different billing countries for all invoices.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT distinct(BillingCountry) FROM INVOICE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the names of all artists that have \"a\" in their names.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM ARTIST WHERE Name LIKE \"%a%\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the names of artist who have the letter 'a' in their names?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM ARTIST WHERE Name LIKE \"%a%\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the title of all the albums of the artist \"AC/DC\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = \"AC/DC\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the titles of albums by the artist \"AC/DC\"?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = \"AC/DC\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Hom many albums does the artist \"Metallica\" have?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = \"Metallica\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the number of albums by the artist \"Metallica\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = \"Metallica\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Which artist does the album \"Balls to the Wall\" belong to?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = \"Balls to the Wall\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the name of the artist who made the album \"Balls to the Wall\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = \"Balls to the Wall\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Which artist has the most albums?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the name of the artist with the greatest number of albums?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the names of all the tracks that contain the word \"you\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM TRACK WHERE Name LIKE '%you%'", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the names of tracks that contain the the word you in them?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM TRACK WHERE Name LIKE '%you%'", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the average unit price of all the tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(UnitPrice) FROM TRACK", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the average unit price for a track.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(UnitPrice) FROM TRACK", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the durations of the longest and the shortest tracks in milliseconds?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the maximum and minimum durations of tracks in milliseconds.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT max(Milliseconds) , min(Milliseconds) FROM TRACK", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Show the album names, ids and the number of tracks for each album.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T1.Title , T2.AlbumID , COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the names and ids of the different albums, and how many tracks are on each?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T1.Title , T2.AlbumID , COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the name of the most common genre in all tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the name of the genre that is most frequent across all tracks.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the least common media type in all tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the name of the media type that is least common across all tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Show the album names and ids for albums that contain tracks with unit price bigger than 1.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the titles and ids for albums containing tracks with unit price greater than 1?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: How many tracks belong to rock genre?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Rock\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Count the number of tracks that are part of the rock genre.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Rock\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the average unit price of tracks that belong to Jazz genre?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Jazz\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the average unit price of jazz tracks.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Jazz\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the first name and last name of the customer that has email \"[email protected]\"?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT FirstName , LastName FROM CUSTOMER WHERE Email = \"[email protected]\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the full name of the customer with the email \"[email protected]\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT FirstName , LastName FROM CUSTOMER WHERE Email = \"[email protected]\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: How many customers have email that contains \"gmail.com\"?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE \"%gmail.com%\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Count the number of customers that have an email containing \"gmail.com\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE \"%gmail.com%\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the first name and last name employee helps the customer with first name Leonie?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.FirstName , T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = \"Leonie\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the full names of employees who help customers with the first name Leonie.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.FirstName , T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = \"Leonie\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What city does the employee who helps the customer with postal code 70174 live in?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = \"70174\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the cities corresponding to employees who help customers with the postal code 70174.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = \"70174\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: How many distinct cities does the employees live in?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(DISTINCT city) FROM EMPLOYEE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the number of different cities that employees live in.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(DISTINCT city) FROM EMPLOYEE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find all invoice dates corresponding to customers with first name Astrid and last name Gruber.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = \"Astrid\" AND LastName = \"Gruber\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the invoice dates for customers with the first name Astrid and the last name Gruber?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = \"Astrid\" AND LastName = \"Gruber\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find all the customer last names that do not have invoice totals larger than 20.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the last names of customers without invoice totals exceeding 20?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the first names of all customers that live in Brazil and have an invoice.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = \"Brazil\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the different first names for customers from Brazil who have also had an invoice?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = \"Brazil\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the address of all customers that live in Germany and have invoice.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = \"Germany\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the addresses of customers living in Germany who have had an invoice?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = \"Germany\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: List the phone numbers of all employees.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Phone FROM EMPLOYEE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the phone numbers for each employee?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Phone FROM EMPLOYEE", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: How many tracks are in the AAC audio file media type?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = \"AAC audio file\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Count the number of tracks that are of the media type \"AAC audio file\".\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = \"AAC audio file\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the average duration in milliseconds of tracks that belong to Latin or Pop genre?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Latin\" OR T1.Name = \"Pop\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the average millisecond length of Latin and Pop tracks.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Latin\" OR T1.Name = \"Pop\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Please show the employee first names and ids of employees who serve at least 10 customers.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the first names and support rep ids for employees serving 10 or more customers?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Please show the employee last names that serves no more than 20 customers.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the last names of employees who serve at most 20 customers?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Please list all album titles in alphabetical order.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Title FROM ALBUM ORDER BY Title", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are all the album titles, in alphabetical order?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Title FROM ALBUM ORDER BY Title", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Please list the name and id of all artists that have at least 3 albums in alphabetical order.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the names and ids of artists with 3 or more albums, listed in alphabetical order?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the names of artists that do not have any albums.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the names of artists who have not released any albums?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What is the average unit price of rock tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Rock\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the average unit price of tracks from the Rock genre.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Rock\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the duration of the longest and shortest pop tracks in milliseconds?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Pop\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the maximum and minimum millisecond lengths of pop tracks.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT max(Milliseconds) , min(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = \"Pop\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the birth dates of employees living in Edmonton?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT BirthDate FROM EMPLOYEE WHERE City = \"Edmonton\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the birth dates corresponding to employees who live in the city of Edmonton.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT BirthDate FROM EMPLOYEE WHERE City = \"Edmonton\"", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the distinct unit prices of all tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT distinct(UnitPrice) FROM TRACK", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the distinct unit prices for tracks.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT distinct(UnitPrice) FROM TRACK", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: How many artists do not have any album?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM)", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Cound the number of artists who have not released an album.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "SELECT count(*) FROM ARTIST WHERE artistid NOT IN(SELECT artistid FROM ALBUM)", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks?\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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'", "role": "assistant" } ]
chinook_1
[ { "content": "Translate the following question to SQL: Find the titles of albums that contain tracks of both the Reggae and Rock genres.\n\nSchema: CREATE TABLE Album (\n AlbumId INTEGER NOT NULL PRIMARY KEY,\n Title varchar(160) NOT NULL,\n ArtistId INTEGER NOT NULL,\n FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)\n);\n\nCREATE TABLE Artist (\n ArtistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Customer (\n CustomerId INTEGER NOT NULL PRIMARY KEY,\n FirstName varchar(40) NOT NULL,\n LastName varchar(20) NOT NULL,\n Company varchar(80) DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) NOT NULL,\n SupportRepId INTEGER DEFAULT NULL,\n FOREIGN KEY (SupportRepId) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Employee (\n EmployeeId INTEGER NOT NULL PRIMARY KEY,\n LastName varchar(20) NOT NULL,\n FirstName varchar(20) NOT NULL,\n Title varchar(30) DEFAULT NULL,\n ReportsTo INTEGER DEFAULT NULL,\n BirthDate datetime DEFAULT NULL,\n HireDate datetime DEFAULT NULL,\n Address varchar(70) DEFAULT NULL,\n City varchar(40) DEFAULT NULL,\n State varchar(40) DEFAULT NULL,\n Country varchar(40) DEFAULT NULL,\n PostalCode varchar(10) DEFAULT NULL,\n Phone varchar(24) DEFAULT NULL,\n Fax varchar(24) DEFAULT NULL,\n Email varchar(60) DEFAULT NULL,\n FOREIGN KEY (ReportsTo) REFERENCES Employee(EmployeeId)\n);\n\nCREATE TABLE Genre (\n GenreId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Invoice (\n InvoiceId INTEGER NOT NULL PRIMARY KEY,\n CustomerId INTEGER NOT NULL,\n InvoiceDate datetime NOT NULL,\n BillingAddress varchar(70) DEFAULT NULL,\n BillingCity varchar(40) DEFAULT NULL,\n BillingState varchar(40) DEFAULT NULL,\n BillingCountry varchar(40) DEFAULT NULL,\n BillingPostalCode varchar(10) DEFAULT NULL,\n Total decimal(10,2) NOT NULL,\n FOREIGN KEY (CustomerId) REFERENCES Customer(CustomerId)\n);\n\nCREATE TABLE InvoiceLine (\n InvoiceLineId INTEGER NOT NULL PRIMARY KEY,\n InvoiceId INTEGER NOT NULL,\n TrackId INTEGER NOT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n Quantity INTEGER NOT NULL,\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (InvoiceId) REFERENCES Invoice(InvoiceId)\n);\n\nCREATE TABLE MediaType (\n MediaTypeId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE Playlist (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(120) DEFAULT NULL\n);\n\nCREATE TABLE PlaylistTrack (\n PlaylistId INTEGER NOT NULL PRIMARY KEY,\n TrackId INTEGER NOT NULL PRIMARY KEY,\n PRIMARY KEY (PlaylistId, TrackId),\n UNIQUE (PlaylistId, TrackId),\n FOREIGN KEY (TrackId) REFERENCES Track(TrackId),\n FOREIGN KEY (PlaylistId) REFERENCES Playlist(PlaylistId)\n);\n\nCREATE TABLE Track (\n TrackId INTEGER NOT NULL PRIMARY KEY,\n Name varchar(200) NOT NULL,\n AlbumId INTEGER DEFAULT NULL,\n MediaTypeId INTEGER NOT NULL,\n GenreId INTEGER DEFAULT NULL,\n Composer varchar(220) DEFAULT NULL,\n Milliseconds INTEGER NOT NULL,\n Bytes INTEGER DEFAULT NULL,\n UnitPrice decimal(10,2) NOT NULL,\n FOREIGN KEY (MediaTypeId) REFERENCES MediaType(MediaTypeId),\n FOREIGN KEY (GenreId) REFERENCES Genre(GenreId),\n FOREIGN KEY (AlbumId) REFERENCES Album(AlbumId)\n);", "role": "user" }, { "content": "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'", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: Find all the phone numbers.\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT customer_phone FROM available_policies", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: What are all the phone numbers?\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT customer_phone FROM available_policies", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: What are the customer phone numbers under the policy \"Life Insurance\"?\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT customer_phone FROM available_policies WHERE policy_type_code = \"Life Insurance\"", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: What are the phone numbers of customers using the policy with the code \"Life Insurance\"?\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT customer_phone FROM available_policies WHERE policy_type_code = \"Life Insurance\"", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: Which policy type has the most records in the database?\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: Which policy type appears most frequently in the available policies?\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY count(*) DESC LIMIT 1", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: What are all the customer phone numbers under the most popular policy type?\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "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)", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: Find the phone numbers of customers using the most common policy type among the available policies.\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "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)", "role": "assistant" } ]
insurance_fnol
[ { "content": "Translate the following question to SQL: Find the policy type used by more than 4 customers.\n\nSchema: CREATE TABLE Customers (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_name VARCHAR(40)\n);\n\nCREATE TABLE Services (\n Service_ID INTEGER NOT NULL PRIMARY KEY,\n Service_name VARCHAR(40)\n);\n\nCREATE TABLE Available_Policies (\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n policy_type_code CHAR(15),\n Customer_Phone VARCHAR(255),\n UNIQUE (Policy_ID)\n);\n\nCREATE TABLE Customers_Policies (\n Customer_ID INTEGER NOT NULL PRIMARY KEY,\n Policy_ID INTEGER NOT NULL PRIMARY KEY,\n Date_Opened DATE,\n Date_Closed DATE,\n PRIMARY KEY (Customer_ID, Policy_ID),\n UNIQUE (Customer_ID, Policy_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Available_Policies(Policy_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)\n);\n\nCREATE TABLE First_Notification_of_Loss (\n FNOL_ID INTEGER NOT NULL PRIMARY KEY,\n Customer_ID INTEGER NOT NULL,\n Policy_ID INTEGER NOT NULL,\n Service_ID INTEGER NOT NULL,\n UNIQUE (FNOL_ID),\n FOREIGN KEY (Customer_ID) REFERENCES Customers_Policies(Customer_ID),\n FOREIGN KEY (Policy_ID) REFERENCES Customers_Policies(Policy_ID),\n FOREIGN KEY (Service_ID) REFERENCES Services(Service_ID)\n);\n\nCREATE TABLE Claims (\n Claim_ID INTEGER NOT NULL PRIMARY KEY,\n FNOL_ID INTEGER NOT NULL,\n Effective_Date DATE,\n UNIQUE (Claim_ID),\n FOREIGN KEY (FNOL_ID) REFERENCES First_Notification_of_Loss(FNOL_ID)\n);\n\nCREATE TABLE Settlements (\n Settlement_ID INTEGER NOT NULL PRIMARY KEY,\n Claim_ID INTEGER,\n Effective_Date DATE,\n Settlement_Amount REAL,\n UNIQUE (Settlement_ID),\n FOREIGN KEY (Claim_ID) REFERENCES Claims(Claim_ID)\n);", "role": "user" }, { "content": "SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING count(*) > 4", "role": "assistant" } ]