question
stringlengths
12
244
context
stringlengths
27
489
answer
stringlengths
18
557
text
stringlengths
114
1.06k
What is the card type code with most number of cards?
CREATE TABLE Customers_cards (card_type_code VARCHAR)
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY COUNT(*) DESC LIMIT 1
### Context: CREATE TABLE Customers_cards (card_type_code VARCHAR) ### Question: What is the card type code with most number of cards? ### Answer: SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY COUNT(*) DESC LIMIT 1
Show card type codes with at least 5 cards.
CREATE TABLE Customers_cards (card_type_code VARCHAR)
SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING COUNT(*) >= 5
### Context: CREATE TABLE Customers_cards (card_type_code VARCHAR) ### Question: Show card type codes with at least 5 cards. ### Answer: SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING COUNT(*) >= 5
Show all card type codes and the number of customers holding cards in each type.
CREATE TABLE Customers_cards (card_type_code VARCHAR, customer_id VARCHAR)
SELECT card_type_code, COUNT(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code
### Context: CREATE TABLE Customers_cards (card_type_code VARCHAR, customer_id VARCHAR) ### Question: Show all card type codes and the number of customers holding cards in each type. ### Answer: SELECT card_type_code, COUNT(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code
Show the customer ids and firstname without a credit card.
CREATE TABLE Customers_cards (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, card_type_code VARCHAR)
SELECT customer_id, customer_first_name FROM Customers EXCEPT SELECT T1.customer_id, T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit"
### Context: CREATE TABLE Customers_cards (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, card_type_code VARCHAR) ### Question: Show the customer ids and firstname without a credit card. ### Answer: SELECT customer_id, customer_first_name FROM Customers EXCEPT SELECT T1.customer_id, T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit"
Show all card type codes.
CREATE TABLE Customers_Cards (card_type_code VARCHAR)
SELECT DISTINCT card_type_code FROM Customers_Cards
### Context: CREATE TABLE Customers_Cards (card_type_code VARCHAR) ### Question: Show all card type codes. ### Answer: SELECT DISTINCT card_type_code FROM Customers_Cards
Show the number of card types.
CREATE TABLE Customers_Cards (card_type_code VARCHAR)
SELECT COUNT(DISTINCT card_type_code) FROM Customers_Cards
### Context: CREATE TABLE Customers_Cards (card_type_code VARCHAR) ### Question: Show the number of card types. ### Answer: SELECT COUNT(DISTINCT card_type_code) FROM Customers_Cards
Show all transaction types.
CREATE TABLE Financial_Transactions (transaction_type VARCHAR)
SELECT DISTINCT transaction_type FROM Financial_Transactions
### Context: CREATE TABLE Financial_Transactions (transaction_type VARCHAR) ### Question: Show all transaction types. ### Answer: SELECT DISTINCT transaction_type FROM Financial_Transactions
Show the number of transaction types.
CREATE TABLE Financial_Transactions (transaction_type VARCHAR)
SELECT COUNT(DISTINCT transaction_type) FROM Financial_Transactions
### Context: CREATE TABLE Financial_Transactions (transaction_type VARCHAR) ### Question: Show the number of transaction types. ### Answer: SELECT COUNT(DISTINCT transaction_type) FROM Financial_Transactions
What is the average and total transaction amount?
CREATE TABLE Financial_transactions (transaction_amount INTEGER)
SELECT AVG(transaction_amount), SUM(transaction_amount) FROM Financial_transactions
### Context: CREATE TABLE Financial_transactions (transaction_amount INTEGER) ### Question: What is the average and total transaction amount? ### Answer: SELECT AVG(transaction_amount), SUM(transaction_amount) FROM Financial_transactions
Show the card type codes and the number of transactions.
CREATE TABLE Financial_transactions (card_id VARCHAR); CREATE TABLE Customers_cards (card_type_code VARCHAR, card_id VARCHAR)
SELECT T2.card_type_code, COUNT(*) FROM Financial_transactions AS T1 JOIN Customers_cards AS T2 ON T1.card_id = T2.card_id GROUP BY T2.card_type_code
### Context: CREATE TABLE Financial_transactions (card_id VARCHAR); CREATE TABLE Customers_cards (card_type_code VARCHAR, card_id VARCHAR) ### Question: Show the card type codes and the number of transactions. ### Answer: SELECT T2.card_type_code, COUNT(*) FROM Financial_transactions AS T1 JOIN Customers_cards AS T2 ON T1.card_id = T2.card_id GROUP BY T2.card_type_code
Show the transaction type and the number of transactions.
CREATE TABLE Financial_transactions (transaction_type VARCHAR)
SELECT transaction_type, COUNT(*) FROM Financial_transactions GROUP BY transaction_type
### Context: CREATE TABLE Financial_transactions (transaction_type VARCHAR) ### Question: Show the transaction type and the number of transactions. ### Answer: SELECT transaction_type, COUNT(*) FROM Financial_transactions GROUP BY transaction_type
What is the transaction type that has processed the greatest total amount in transactions?
CREATE TABLE Financial_transactions (transaction_type VARCHAR, transaction_amount INTEGER)
SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY SUM(transaction_amount) DESC LIMIT 1
### Context: CREATE TABLE Financial_transactions (transaction_type VARCHAR, transaction_amount INTEGER) ### Question: What is the transaction type that has processed the greatest total amount in transactions? ### Answer: SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY SUM(transaction_amount) DESC LIMIT 1
Show the account id and the number of transactions for each account
CREATE TABLE Financial_transactions (account_id VARCHAR)
SELECT account_id, COUNT(*) FROM Financial_transactions GROUP BY account_id
### Context: CREATE TABLE Financial_transactions (account_id VARCHAR) ### Question: Show the account id and the number of transactions for each account ### Answer: SELECT account_id, COUNT(*) FROM Financial_transactions GROUP BY account_id
How many tracks do we have?
CREATE TABLE track (Id VARCHAR)
SELECT COUNT(*) FROM track
### Context: CREATE TABLE track (Id VARCHAR) ### Question: How many tracks do we have? ### Answer: SELECT COUNT(*) FROM track
Show the name and location for all tracks.
CREATE TABLE track (name VARCHAR, LOCATION VARCHAR)
SELECT name, LOCATION FROM track
### Context: CREATE TABLE track (name VARCHAR, LOCATION VARCHAR) ### Question: Show the name and location for all tracks. ### Answer: SELECT name, LOCATION FROM track
Show names and seatings, ordered by seating for all tracks opened after 2000.
CREATE TABLE track (name VARCHAR, seating VARCHAR, year_opened INTEGER)
SELECT name, seating FROM track WHERE year_opened > 2000 ORDER BY seating
### Context: CREATE TABLE track (name VARCHAR, seating VARCHAR, year_opened INTEGER) ### Question: Show names and seatings, ordered by seating for all tracks opened after 2000. ### Answer: SELECT name, seating FROM track WHERE year_opened > 2000 ORDER BY seating
What is the name, location and seating for the most recently opened track?
CREATE TABLE track (name VARCHAR, LOCATION VARCHAR, seating VARCHAR, year_opened VARCHAR)
SELECT name, LOCATION, seating FROM track ORDER BY year_opened DESC LIMIT 1
### Context: CREATE TABLE track (name VARCHAR, LOCATION VARCHAR, seating VARCHAR, year_opened VARCHAR) ### Question: What is the name, location and seating for the most recently opened track? ### Answer: SELECT name, LOCATION, seating FROM track ORDER BY year_opened DESC LIMIT 1
What is the minimum, maximum, and average seating for all tracks.
CREATE TABLE track (seating INTEGER)
SELECT MIN(seating), MAX(seating), AVG(seating) FROM track
### Context: CREATE TABLE track (seating INTEGER) ### Question: What is the minimum, maximum, and average seating for all tracks. ### Answer: SELECT MIN(seating), MAX(seating), AVG(seating) FROM track
Show the name, location, open year for all tracks with a seating higher than the average.
CREATE TABLE track (name VARCHAR, LOCATION VARCHAR, year_opened VARCHAR, seating INTEGER)
SELECT name, LOCATION, year_opened FROM track WHERE seating > (SELECT AVG(seating) FROM track)
### Context: CREATE TABLE track (name VARCHAR, LOCATION VARCHAR, year_opened VARCHAR, seating INTEGER) ### Question: Show the name, location, open year for all tracks with a seating higher than the average. ### Answer: SELECT name, LOCATION, year_opened FROM track WHERE seating > (SELECT AVG(seating) FROM track)
What are distinct locations where tracks are located?
CREATE TABLE track (LOCATION VARCHAR)
SELECT DISTINCT LOCATION FROM track
### Context: CREATE TABLE track (LOCATION VARCHAR) ### Question: What are distinct locations where tracks are located? ### Answer: SELECT DISTINCT LOCATION FROM track
How many races are there?
CREATE TABLE race (Id VARCHAR)
SELECT COUNT(*) FROM race
### Context: CREATE TABLE race (Id VARCHAR) ### Question: How many races are there? ### Answer: SELECT COUNT(*) FROM race
What are the distinct classes that races can have?
CREATE TABLE race (CLASS VARCHAR)
SELECT DISTINCT CLASS FROM race
### Context: CREATE TABLE race (CLASS VARCHAR) ### Question: What are the distinct classes that races can have? ### Answer: SELECT DISTINCT CLASS FROM race
Show name, class, and date for all races.
CREATE TABLE race (name VARCHAR, CLASS VARCHAR, date VARCHAR)
SELECT name, CLASS, date FROM race
### Context: CREATE TABLE race (name VARCHAR, CLASS VARCHAR, date VARCHAR) ### Question: Show name, class, and date for all races. ### Answer: SELECT name, CLASS, date FROM race
Show the race class and number of races in each class.
CREATE TABLE race (CLASS VARCHAR)
SELECT CLASS, COUNT(*) FROM race GROUP BY CLASS
### Context: CREATE TABLE race (CLASS VARCHAR) ### Question: Show the race class and number of races in each class. ### Answer: SELECT CLASS, COUNT(*) FROM race GROUP BY CLASS
What is the race class with most number of races.
CREATE TABLE race (CLASS VARCHAR)
SELECT CLASS FROM race GROUP BY CLASS ORDER BY COUNT(*) DESC LIMIT 1
### Context: CREATE TABLE race (CLASS VARCHAR) ### Question: What is the race class with most number of races. ### Answer: SELECT CLASS FROM race GROUP BY CLASS ORDER BY COUNT(*) DESC LIMIT 1
List the race class with at least two races.
CREATE TABLE race (CLASS VARCHAR)
SELECT CLASS FROM race GROUP BY CLASS HAVING COUNT(*) >= 2
### Context: CREATE TABLE race (CLASS VARCHAR) ### Question: List the race class with at least two races. ### Answer: SELECT CLASS FROM race GROUP BY CLASS HAVING COUNT(*) >= 2
What are the names for tracks without a race in class 'GT'.
CREATE TABLE race (track_id VARCHAR, class VARCHAR); CREATE TABLE track (name VARCHAR); CREATE TABLE track (name VARCHAR, track_id VARCHAR)
SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id WHERE T1.class = 'GT'
### Context: CREATE TABLE race (track_id VARCHAR, class VARCHAR); CREATE TABLE track (name VARCHAR); CREATE TABLE track (name VARCHAR, track_id VARCHAR) ### Question: What are the names for tracks without a race in class 'GT'. ### Answer: SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id WHERE T1.class = 'GT'
Show all track names that have had no races.
CREATE TABLE track (name VARCHAR, track_id VARCHAR); CREATE TABLE race (name VARCHAR, track_id VARCHAR)
SELECT name FROM track WHERE NOT track_id IN (SELECT track_id FROM race)
### Context: CREATE TABLE track (name VARCHAR, track_id VARCHAR); CREATE TABLE race (name VARCHAR, track_id VARCHAR) ### Question: Show all track names that have had no races. ### Answer: SELECT name FROM track WHERE NOT track_id IN (SELECT track_id FROM race)
Show year where a track with a seating at least 5000 opened and a track with seating no more than 4000 opened.
CREATE TABLE track (year_opened VARCHAR, seating INTEGER)
SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000
### Context: CREATE TABLE track (year_opened VARCHAR, seating INTEGER) ### Question: Show year where a track with a seating at least 5000 opened and a track with seating no more than 4000 opened. ### Answer: SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000
Show the name of track and the number of races in each track.
CREATE TABLE track (name VARCHAR, track_id VARCHAR); CREATE TABLE race (track_id VARCHAR)
SELECT T2.name, COUNT(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id
### Context: CREATE TABLE track (name VARCHAR, track_id VARCHAR); CREATE TABLE race (track_id VARCHAR) ### Question: Show the name of track and the number of races in each track. ### Answer: SELECT T2.name, COUNT(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id
Show the name of track with most number of races.
CREATE TABLE track (name VARCHAR, track_id VARCHAR); CREATE TABLE race (track_id VARCHAR)
SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY COUNT(*) DESC LIMIT 1
### Context: CREATE TABLE track (name VARCHAR, track_id VARCHAR); CREATE TABLE race (track_id VARCHAR) ### Question: Show the name of track with most number of races. ### Answer: SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY COUNT(*) DESC LIMIT 1
Show the name and date for each race and its track name.
CREATE TABLE race (name VARCHAR, date VARCHAR, track_id VARCHAR); CREATE TABLE track (name VARCHAR, track_id VARCHAR)
SELECT T1.name, T1.date, T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id
### Context: CREATE TABLE race (name VARCHAR, date VARCHAR, track_id VARCHAR); CREATE TABLE track (name VARCHAR, track_id VARCHAR) ### Question: Show the name and date for each race and its track name. ### Answer: SELECT T1.name, T1.date, T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id
Show the name and location of track with 1 race.
CREATE TABLE race (track_id VARCHAR); CREATE TABLE track (name VARCHAR, location VARCHAR, track_id VARCHAR)
SELECT T2.name, T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id HAVING COUNT(*) = 1
### Context: CREATE TABLE race (track_id VARCHAR); CREATE TABLE track (name VARCHAR, location VARCHAR, track_id VARCHAR) ### Question: Show the name and location of track with 1 race. ### Answer: SELECT T2.name, T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id HAVING COUNT(*) = 1
Find the locations where have both tracks with more than 90000 seats and tracks with less than 70000 seats.
CREATE TABLE track (LOCATION VARCHAR, seating INTEGER)
SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000
### Context: CREATE TABLE track (LOCATION VARCHAR, seating INTEGER) ### Question: Find the locations where have both tracks with more than 90000 seats and tracks with less than 70000 seats. ### Answer: SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000
How many members have the black membership card?
CREATE TABLE member (Membership_card VARCHAR)
SELECT COUNT(*) FROM member WHERE Membership_card = 'Black'
### Context: CREATE TABLE member (Membership_card VARCHAR) ### Question: How many members have the black membership card? ### Answer: SELECT COUNT(*) FROM member WHERE Membership_card = 'Black'
Find the number of members living in each address.
CREATE TABLE member (address VARCHAR)
SELECT COUNT(*), address FROM member GROUP BY address
### Context: CREATE TABLE member (address VARCHAR) ### Question: Find the number of members living in each address. ### Answer: SELECT COUNT(*), address FROM member GROUP BY address
Give me the names of members whose address is in Harford or Waterbury.
CREATE TABLE member (name VARCHAR, address VARCHAR)
SELECT name FROM member WHERE address = 'Harford' OR address = 'Waterbury'
### Context: CREATE TABLE member (name VARCHAR, address VARCHAR) ### Question: Give me the names of members whose address is in Harford or Waterbury. ### Answer: SELECT name FROM member WHERE address = 'Harford' OR address = 'Waterbury'
Find the ids and names of members who are under age 30 or with black membership card.
CREATE TABLE member (name VARCHAR, member_id VARCHAR, Membership_card VARCHAR, age VARCHAR)
SELECT name, member_id FROM member WHERE Membership_card = 'Black' OR age < 30
### Context: CREATE TABLE member (name VARCHAR, member_id VARCHAR, Membership_card VARCHAR, age VARCHAR) ### Question: Find the ids and names of members who are under age 30 or with black membership card. ### Answer: SELECT name, member_id FROM member WHERE Membership_card = 'Black' OR age < 30
Find the purchase time, age and address of each member, and show the results in the order of purchase time.
CREATE TABLE member (Time_of_purchase VARCHAR, age VARCHAR, address VARCHAR)
SELECT Time_of_purchase, age, address FROM member ORDER BY Time_of_purchase
### Context: CREATE TABLE member (Time_of_purchase VARCHAR, age VARCHAR, address VARCHAR) ### Question: Find the purchase time, age and address of each member, and show the results in the order of purchase time. ### Answer: SELECT Time_of_purchase, age, address FROM member ORDER BY Time_of_purchase
Which membership card has more than 5 members?
CREATE TABLE member (Membership_card VARCHAR)
SELECT Membership_card FROM member GROUP BY Membership_card HAVING COUNT(*) > 5
### Context: CREATE TABLE member (Membership_card VARCHAR) ### Question: Which membership card has more than 5 members? ### Answer: SELECT Membership_card FROM member GROUP BY Membership_card HAVING COUNT(*) > 5
Which address has both members younger than 30 and members older than 40?
CREATE TABLE member (address VARCHAR, age INTEGER)
SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40
### Context: CREATE TABLE member (address VARCHAR, age INTEGER) ### Question: Which address has both members younger than 30 and members older than 40? ### Answer: SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40
What is the membership card held by both members living in Hartford and ones living in Waterbury address?
CREATE TABLE member (membership_card VARCHAR, address VARCHAR)
SELECT membership_card FROM member WHERE address = 'Hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'Waterbury'
### Context: CREATE TABLE member (membership_card VARCHAR, address VARCHAR) ### Question: What is the membership card held by both members living in Hartford and ones living in Waterbury address? ### Answer: SELECT membership_card FROM member WHERE address = 'Hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'Waterbury'
How many members are not living in Hartford?
CREATE TABLE member (address VARCHAR)
SELECT COUNT(*) FROM member WHERE address <> 'Hartford'
### Context: CREATE TABLE member (address VARCHAR) ### Question: How many members are not living in Hartford? ### Answer: SELECT COUNT(*) FROM member WHERE address <> 'Hartford'
Which address do not have any member with the black membership card?
CREATE TABLE member (address VARCHAR, Membership_card VARCHAR)
SELECT address FROM member EXCEPT SELECT address FROM member WHERE Membership_card = 'Black'
### Context: CREATE TABLE member (address VARCHAR, Membership_card VARCHAR) ### Question: Which address do not have any member with the black membership card? ### Answer: SELECT address FROM member EXCEPT SELECT address FROM member WHERE Membership_card = 'Black'
Show the shop addresses ordered by their opening year.
CREATE TABLE shop (address VARCHAR, open_year VARCHAR)
SELECT address FROM shop ORDER BY open_year
### Context: CREATE TABLE shop (address VARCHAR, open_year VARCHAR) ### Question: Show the shop addresses ordered by their opening year. ### Answer: SELECT address FROM shop ORDER BY open_year
What are the average score and average staff number of all shops?
CREATE TABLE shop (num_of_staff INTEGER, score INTEGER)
SELECT AVG(num_of_staff), AVG(score) FROM shop
### Context: CREATE TABLE shop (num_of_staff INTEGER, score INTEGER) ### Question: What are the average score and average staff number of all shops? ### Answer: SELECT AVG(num_of_staff), AVG(score) FROM shop
Find the id and address of the shops whose score is below the average score.
CREATE TABLE shop (shop_id VARCHAR, address VARCHAR, score INTEGER)
SELECT shop_id, address FROM shop WHERE score < (SELECT AVG(score) FROM shop)
### Context: CREATE TABLE shop (shop_id VARCHAR, address VARCHAR, score INTEGER) ### Question: Find the id and address of the shops whose score is below the average score. ### Answer: SELECT shop_id, address FROM shop WHERE score < (SELECT AVG(score) FROM shop)
Find the address and staff number of the shops that do not have any happy hour.
CREATE TABLE shop (address VARCHAR, num_of_staff VARCHAR, shop_id VARCHAR); CREATE TABLE happy_hour (address VARCHAR, num_of_staff VARCHAR, shop_id VARCHAR)
SELECT address, num_of_staff FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM happy_hour)
### Context: CREATE TABLE shop (address VARCHAR, num_of_staff VARCHAR, shop_id VARCHAR); CREATE TABLE happy_hour (address VARCHAR, num_of_staff VARCHAR, shop_id VARCHAR) ### Question: Find the address and staff number of the shops that do not have any happy hour. ### Answer: SELECT address, num_of_staff FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM happy_hour)
What are the id and address of the shops which have a happy hour in May?
CREATE TABLE shop (address VARCHAR, shop_id VARCHAR); CREATE TABLE happy_hour (shop_id VARCHAR)
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'
### Context: CREATE TABLE shop (address VARCHAR, shop_id VARCHAR); CREATE TABLE happy_hour (shop_id VARCHAR) ### Question: What are the id and address of the shops which have a happy hour in May? ### Answer: 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'
which shop has happy hour most frequently? List its id and number of happy hours.
CREATE TABLE happy_hour (shop_id VARCHAR)
SELECT shop_id, COUNT(*) FROM happy_hour GROUP BY shop_id ORDER BY COUNT(*) DESC LIMIT 1
### Context: CREATE TABLE happy_hour (shop_id VARCHAR) ### Question: which shop has happy hour most frequently? List its id and number of happy hours. ### Answer: SELECT shop_id, COUNT(*) FROM happy_hour GROUP BY shop_id ORDER BY COUNT(*) DESC LIMIT 1
Which month has the most happy hours?
CREATE TABLE happy_hour (MONTH VARCHAR)
SELECT MONTH FROM happy_hour GROUP BY MONTH ORDER BY COUNT(*) DESC LIMIT 1
### Context: CREATE TABLE happy_hour (MONTH VARCHAR) ### Question: Which month has the most happy hours? ### Answer: SELECT MONTH FROM happy_hour GROUP BY MONTH ORDER BY COUNT(*) DESC LIMIT 1
Which months have more than 2 happy hours?
CREATE TABLE happy_hour (MONTH VARCHAR)
SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING COUNT(*) > 2
### Context: CREATE TABLE happy_hour (MONTH VARCHAR) ### Question: Which months have more than 2 happy hours? ### Answer: SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING COUNT(*) > 2
How many albums are there?
CREATE TABLE ALBUM (Id VARCHAR)
SELECT COUNT(*) FROM ALBUM
### Context: CREATE TABLE ALBUM (Id VARCHAR) ### Question: How many albums are there? ### Answer: SELECT COUNT(*) FROM ALBUM
List the names of all music genres.
CREATE TABLE GENRE (Name VARCHAR)
SELECT Name FROM GENRE
### Context: CREATE TABLE GENRE (Name VARCHAR) ### Question: List the names of all music genres. ### Answer: SELECT Name FROM GENRE
Find all the customer information in state NY.
CREATE TABLE CUSTOMER (State VARCHAR)
SELECT * FROM CUSTOMER WHERE State = "NY"
### Context: CREATE TABLE CUSTOMER (State VARCHAR) ### Question: Find all the customer information in state NY. ### Answer: SELECT * FROM CUSTOMER WHERE State = "NY"
What are the first names and last names of the employees who live in Calgary city.
CREATE TABLE EMPLOYEE (FirstName VARCHAR, LastName VARCHAR, City VARCHAR)
SELECT FirstName, LastName FROM EMPLOYEE WHERE City = "Calgary"
### Context: CREATE TABLE EMPLOYEE (FirstName VARCHAR, LastName VARCHAR, City VARCHAR) ### Question: What are the first names and last names of the employees who live in Calgary city. ### Answer: SELECT FirstName, LastName FROM EMPLOYEE WHERE City = "Calgary"
What are the distinct billing countries of the invoices?
CREATE TABLE INVOICE (BillingCountry VARCHAR)
SELECT DISTINCT (BillingCountry) FROM INVOICE
### Context: CREATE TABLE INVOICE (BillingCountry VARCHAR) ### Question: What are the distinct billing countries of the invoices? ### Answer: SELECT DISTINCT (BillingCountry) FROM INVOICE
Find the names of all artists that have "a" in their names.
CREATE TABLE ARTIST (Name VARCHAR)
SELECT Name FROM ARTIST WHERE Name LIKE "%a%"
### Context: CREATE TABLE ARTIST (Name VARCHAR) ### Question: Find the names of all artists that have "a" in their names. ### Answer: SELECT Name FROM ARTIST WHERE Name LIKE "%a%"
Find the title of all the albums of the artist "AC/DC".
CREATE TABLE ARTIST (ArtistId VARCHAR, Name VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR)
SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "AC/DC"
### Context: CREATE TABLE ARTIST (ArtistId VARCHAR, Name VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR) ### Question: Find the title of all the albums of the artist "AC/DC". ### Answer: SELECT Title FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "AC/DC"
Hom many albums does the artist "Metallica" have?
CREATE TABLE ARTIST (ArtistId VARCHAR, Name VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR)
SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "Metallica"
### Context: CREATE TABLE ARTIST (ArtistId VARCHAR, Name VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR) ### Question: Hom many albums does the artist "Metallica" have? ### Answer: SELECT COUNT(*) FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T2.Name = "Metallica"
Which artist does the album "Balls to the Wall" belong to?
CREATE TABLE ALBUM (ArtistId VARCHAR, Title VARCHAR); CREATE TABLE ARTIST (Name VARCHAR, ArtistId VARCHAR)
SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = "Balls to the Wall"
### Context: CREATE TABLE ALBUM (ArtistId VARCHAR, Title VARCHAR); CREATE TABLE ARTIST (Name VARCHAR, ArtistId VARCHAR) ### Question: Which artist does the album "Balls to the Wall" belong to? ### Answer: SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId WHERE T1.Title = "Balls to the Wall"
Which artist has the most albums?
CREATE TABLE ALBUM (ArtistId VARCHAR); CREATE TABLE ARTIST (Name VARCHAR, ArtistId VARCHAR)
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
### Context: CREATE TABLE ALBUM (ArtistId VARCHAR); CREATE TABLE ARTIST (Name VARCHAR, ArtistId VARCHAR) ### Question: Which artist has the most albums? ### Answer: 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
Find the names of all the tracks that contain the word "you".
CREATE TABLE TRACK (Name VARCHAR)
SELECT Name FROM TRACK WHERE Name LIKE '%you%'
### Context: CREATE TABLE TRACK (Name VARCHAR) ### Question: Find the names of all the tracks that contain the word "you". ### Answer: SELECT Name FROM TRACK WHERE Name LIKE '%you%'
What is the average unit price of all the tracks?
CREATE TABLE TRACK (UnitPrice INTEGER)
SELECT AVG(UnitPrice) FROM TRACK
### Context: CREATE TABLE TRACK (UnitPrice INTEGER) ### Question: What is the average unit price of all the tracks? ### Answer: SELECT AVG(UnitPrice) FROM TRACK
What are the durations of the longest and the shortest tracks in milliseconds?
CREATE TABLE TRACK (Milliseconds INTEGER)
SELECT MAX(Milliseconds), MIN(Milliseconds) FROM TRACK
### Context: CREATE TABLE TRACK (Milliseconds INTEGER) ### Question: What are the durations of the longest and the shortest tracks in milliseconds? ### Answer: SELECT MAX(Milliseconds), MIN(Milliseconds) FROM TRACK
Show the album names, ids and the number of tracks for each album.
CREATE TABLE ALBUM (Title VARCHAR, AlbumId VARCHAR); CREATE TABLE TRACK (AlbumID VARCHAR, AlbumId VARCHAR)
SELECT T1.Title, T2.AlbumID, COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID
### Context: CREATE TABLE ALBUM (Title VARCHAR, AlbumId VARCHAR); CREATE TABLE TRACK (AlbumID VARCHAR, AlbumId VARCHAR) ### Question: Show the album names, ids and the number of tracks for each album. ### Answer: SELECT T1.Title, T2.AlbumID, COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID
What is the name of the most common genre in all tracks?
CREATE TABLE GENRE (Name VARCHAR, GenreId VARCHAR); CREATE TABLE TRACK (GenreId VARCHAR)
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
### Context: CREATE TABLE GENRE (Name VARCHAR, GenreId VARCHAR); CREATE TABLE TRACK (GenreId VARCHAR) ### Question: What is the name of the most common genre in all tracks? ### Answer: 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
What is the least common media type in all tracks?
CREATE TABLE MEDIATYPE (Name VARCHAR, MediaTypeId VARCHAR); CREATE TABLE TRACK (MediaTypeId VARCHAR)
SELECT T1.Name FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.MediaTypeId ORDER BY COUNT(*) LIMIT 1
### Context: CREATE TABLE MEDIATYPE (Name VARCHAR, MediaTypeId VARCHAR); CREATE TABLE TRACK (MediaTypeId VARCHAR) ### Question: What is the least common media type in all tracks? ### Answer: SELECT T1.Name FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId GROUP BY T2.MediaTypeId ORDER BY COUNT(*) LIMIT 1
Show the album names and ids for albums that contain tracks with unit price bigger than 1.
CREATE TABLE ALBUM (Title VARCHAR, AlbumId VARCHAR); CREATE TABLE TRACK (AlbumID VARCHAR, AlbumId VARCHAR, UnitPrice INTEGER)
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
### Context: CREATE TABLE ALBUM (Title VARCHAR, AlbumId VARCHAR); CREATE TABLE TRACK (AlbumID VARCHAR, AlbumId VARCHAR, UnitPrice INTEGER) ### Question: Show the album names and ids for albums that contain tracks with unit price bigger than 1. ### Answer: 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
How many tracks belong to rock genre?
CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR)
SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock"
### Context: CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR) ### Question: How many tracks belong to rock genre? ### Answer: SELECT COUNT(*) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock"
What is the average unit price of tracks that belong to Jazz genre?
CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR)
SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Jazz"
### Context: CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR) ### Question: What is the average unit price of tracks that belong to Jazz genre? ### Answer: SELECT AVG(UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Jazz"
What is the first name and last name of the customer that has email "luisg@embraer.com.br"?
CREATE TABLE CUSTOMER (FirstName VARCHAR, LastName VARCHAR, Email VARCHAR)
SELECT FirstName, LastName FROM CUSTOMER WHERE Email = "luisg@embraer.com.br"
### Context: CREATE TABLE CUSTOMER (FirstName VARCHAR, LastName VARCHAR, Email VARCHAR) ### Question: What is the first name and last name of the customer that has email "luisg@embraer.com.br"? ### Answer: SELECT FirstName, LastName FROM CUSTOMER WHERE Email = "luisg@embraer.com.br"
How many customers have email that contains "gmail.com"?
CREATE TABLE CUSTOMER (Email VARCHAR)
SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%"
### Context: CREATE TABLE CUSTOMER (Email VARCHAR) ### Question: How many customers have email that contains "gmail.com"? ### Answer: SELECT COUNT(*) FROM CUSTOMER WHERE Email LIKE "%gmail.com%"
What is the first name and last name employee helps the customer with first name Leonie?
CREATE TABLE CUSTOMER (SupportRepId VARCHAR, FirstName VARCHAR); CREATE TABLE EMPLOYEE (FirstName VARCHAR, LastName VARCHAR, EmployeeId VARCHAR)
SELECT T2.FirstName, T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = "Leonie"
### Context: CREATE TABLE CUSTOMER (SupportRepId VARCHAR, FirstName VARCHAR); CREATE TABLE EMPLOYEE (FirstName VARCHAR, LastName VARCHAR, EmployeeId VARCHAR) ### Question: What is the first name and last name employee helps the customer with first name Leonie? ### Answer: SELECT T2.FirstName, T2.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.FirstName = "Leonie"
What city does the employee who helps the customer with postal code 70174 live in?
CREATE TABLE EMPLOYEE (City VARCHAR, EmployeeId VARCHAR); CREATE TABLE CUSTOMER (SupportRepId VARCHAR, PostalCode VARCHAR)
SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = "70174"
### Context: CREATE TABLE EMPLOYEE (City VARCHAR, EmployeeId VARCHAR); CREATE TABLE CUSTOMER (SupportRepId VARCHAR, PostalCode VARCHAR) ### Question: What city does the employee who helps the customer with postal code 70174 live in? ### Answer: SELECT T2.City FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId WHERE T1.PostalCode = "70174"
How many distinct cities does the employees live in?
CREATE TABLE EMPLOYEE (city VARCHAR)
SELECT COUNT(DISTINCT city) FROM EMPLOYEE
### Context: CREATE TABLE EMPLOYEE (city VARCHAR) ### Question: How many distinct cities does the employees live in? ### Answer: SELECT COUNT(DISTINCT city) FROM EMPLOYEE
Find all invoice dates corresponding to customers with first name Astrid and last name Gruber.
CREATE TABLE CUSTOMER (CustomerId VARCHAR, FirstName VARCHAR); CREATE TABLE INVOICE (InvoiceDate VARCHAR, CustomerId VARCHAR)
SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = "Astrid" AND LastName = "Gruber"
### Context: CREATE TABLE CUSTOMER (CustomerId VARCHAR, FirstName VARCHAR); CREATE TABLE INVOICE (InvoiceDate VARCHAR, CustomerId VARCHAR) ### Question: Find all invoice dates corresponding to customers with first name Astrid and last name Gruber. ### Answer: SELECT T2.InvoiceDate FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.FirstName = "Astrid" AND LastName = "Gruber"
Find all the customer last names that do not have invoice totals larger than 20.
CREATE TABLE CUSTOMER (LastName VARCHAR); CREATE TABLE CUSTOMER (LastName VARCHAR, CustomerId VARCHAR); CREATE TABLE Invoice (CustomerId VARCHAR, total INTEGER)
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
### Context: CREATE TABLE CUSTOMER (LastName VARCHAR); CREATE TABLE CUSTOMER (LastName VARCHAR, CustomerId VARCHAR); CREATE TABLE Invoice (CustomerId VARCHAR, total INTEGER) ### Question: Find all the customer last names that do not have invoice totals larger than 20. ### Answer: 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
Find the first names of all customers that live in Brazil and have an invoice.
CREATE TABLE CUSTOMER (FirstName VARCHAR, CustomerId VARCHAR, country VARCHAR); CREATE TABLE INVOICE (CustomerId VARCHAR)
SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Brazil"
### Context: CREATE TABLE CUSTOMER (FirstName VARCHAR, CustomerId VARCHAR, country VARCHAR); CREATE TABLE INVOICE (CustomerId VARCHAR) ### Question: Find the first names of all customers that live in Brazil and have an invoice. ### Answer: SELECT DISTINCT T1.FirstName FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Brazil"
Find the address of all customers that live in Germany and have invoice.
CREATE TABLE INVOICE (CustomerId VARCHAR); CREATE TABLE CUSTOMER (Address VARCHAR, CustomerId VARCHAR, country VARCHAR)
SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Germany"
### Context: CREATE TABLE INVOICE (CustomerId VARCHAR); CREATE TABLE CUSTOMER (Address VARCHAR, CustomerId VARCHAR, country VARCHAR) ### Question: Find the address of all customers that live in Germany and have invoice. ### Answer: SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = "Germany"
List the phone numbers of all employees.
CREATE TABLE EMPLOYEE (Phone VARCHAR)
SELECT Phone FROM EMPLOYEE
### Context: CREATE TABLE EMPLOYEE (Phone VARCHAR) ### Question: List the phone numbers of all employees. ### Answer: SELECT Phone FROM EMPLOYEE
How many tracks are in the AAC audio file media type?
CREATE TABLE MEDIATYPE (MediaTypeId VARCHAR, Name VARCHAR); CREATE TABLE TRACK (MediaTypeId VARCHAR)
SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = "AAC audio file"
### Context: CREATE TABLE MEDIATYPE (MediaTypeId VARCHAR, Name VARCHAR); CREATE TABLE TRACK (MediaTypeId VARCHAR) ### Question: How many tracks are in the AAC audio file media type? ### Answer: SELECT COUNT(*) FROM MEDIATYPE AS T1 JOIN TRACK AS T2 ON T1.MediaTypeId = T2.MediaTypeId WHERE T1.Name = "AAC audio file"
What is the average duration in milliseconds of tracks that belong to Latin or Pop genre?
CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR)
SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Latin" OR T1.Name = "Pop"
### Context: CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR) ### Question: What is the average duration in milliseconds of tracks that belong to Latin or Pop genre? ### Answer: SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Latin" OR T1.Name = "Pop"
Please show the employee first names and ids of employees who serve at least 10 customers.
CREATE TABLE CUSTOMER (FirstName VARCHAR, SupportRepId VARCHAR); CREATE TABLE EMPLOYEE (EmployeeId VARCHAR)
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
### Context: CREATE TABLE CUSTOMER (FirstName VARCHAR, SupportRepId VARCHAR); CREATE TABLE EMPLOYEE (EmployeeId VARCHAR) ### Question: Please show the employee first names and ids of employees who serve at least 10 customers. ### Answer: 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
Please show the employee last names that serves no more than 20 customers.
CREATE TABLE EMPLOYEE (EmployeeId VARCHAR); CREATE TABLE CUSTOMER (LastName VARCHAR, SupportRepId VARCHAR)
SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20
### Context: CREATE TABLE EMPLOYEE (EmployeeId VARCHAR); CREATE TABLE CUSTOMER (LastName VARCHAR, SupportRepId VARCHAR) ### Question: Please show the employee last names that serves no more than 20 customers. ### Answer: SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20
Please list all album titles in alphabetical order.
CREATE TABLE ALBUM (Title VARCHAR)
SELECT Title FROM ALBUM ORDER BY Title
### Context: CREATE TABLE ALBUM (Title VARCHAR) ### Question: Please list all album titles in alphabetical order. ### Answer: SELECT Title FROM ALBUM ORDER BY Title
Please list the name and id of all artists that have at least 3 albums in alphabetical order.
CREATE TABLE ARTIST (Name VARCHAR, ArtistID VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR)
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
### Context: CREATE TABLE ARTIST (Name VARCHAR, ArtistID VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR) ### Question: Please list the name and id of all artists that have at least 3 albums in alphabetical order. ### Answer: 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
Find the names of artists that do not have any albums.
CREATE TABLE ARTIST (Name VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR); CREATE TABLE ARTIST (Name VARCHAR, ArtistId VARCHAR)
SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId
### Context: CREATE TABLE ARTIST (Name VARCHAR); CREATE TABLE ALBUM (ArtistId VARCHAR); CREATE TABLE ARTIST (Name VARCHAR, ArtistId VARCHAR) ### Question: Find the names of artists that do not have any albums. ### Answer: SELECT Name FROM ARTIST EXCEPT SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId
What is the average unit price of rock tracks?
CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR); CREATE TABLE TRACK (UnitPrice INTEGER, GenreId VARCHAR)
SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock"
### Context: CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR); CREATE TABLE TRACK (UnitPrice INTEGER, GenreId VARCHAR) ### Question: What is the average unit price of rock tracks? ### Answer: SELECT AVG(T2.UnitPrice) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Rock"
What are the duration of the longest and shortest pop tracks in milliseconds?
CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR)
SELECT MAX(Milliseconds), MIN(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Pop"
### Context: CREATE TABLE TRACK (GenreId VARCHAR); CREATE TABLE GENRE (GenreId VARCHAR, Name VARCHAR) ### Question: What are the duration of the longest and shortest pop tracks in milliseconds? ### Answer: SELECT MAX(Milliseconds), MIN(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = "Pop"
What are the birth dates of employees living in Edmonton?
CREATE TABLE EMPLOYEE (BirthDate VARCHAR, City VARCHAR)
SELECT BirthDate FROM EMPLOYEE WHERE City = "Edmonton"
### Context: CREATE TABLE EMPLOYEE (BirthDate VARCHAR, City VARCHAR) ### Question: What are the birth dates of employees living in Edmonton? ### Answer: SELECT BirthDate FROM EMPLOYEE WHERE City = "Edmonton"
What are the distinct unit prices of all tracks?
CREATE TABLE TRACK (UnitPrice VARCHAR)
SELECT DISTINCT (UnitPrice) FROM TRACK
### Context: CREATE TABLE TRACK (UnitPrice VARCHAR) ### Question: What are the distinct unit prices of all tracks? ### Answer: SELECT DISTINCT (UnitPrice) FROM TRACK
How many artists do not have any album?
CREATE TABLE ARTIST (artistid VARCHAR); CREATE TABLE ALBUM (artistid VARCHAR)
SELECT COUNT(*) FROM ARTIST WHERE NOT artistid IN (SELECT artistid FROM ALBUM)
### Context: CREATE TABLE ARTIST (artistid VARCHAR); CREATE TABLE ALBUM (artistid VARCHAR) ### Question: How many artists do not have any album? ### Answer: SELECT COUNT(*) FROM ARTIST WHERE NOT artistid IN (SELECT artistid FROM ALBUM)
What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks?
CREATE TABLE Genre (GenreID VARCHAR, Name VARCHAR); CREATE TABLE Track (AlbumId VARCHAR, GenreID VARCHAR); CREATE TABLE Album (Title VARCHAR, AlbumId VARCHAR)
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'
### Context: CREATE TABLE Genre (GenreID VARCHAR, Name VARCHAR); CREATE TABLE Track (AlbumId VARCHAR, GenreID VARCHAR); CREATE TABLE Album (Title VARCHAR, AlbumId VARCHAR) ### Question: What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks? ### Answer: 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'
Find all the phone numbers.
CREATE TABLE available_policies (customer_phone VARCHAR)
SELECT customer_phone FROM available_policies
### Context: CREATE TABLE available_policies (customer_phone VARCHAR) ### Question: Find all the phone numbers. ### Answer: SELECT customer_phone FROM available_policies
What are the customer phone numbers under the policy "Life Insurance"?
CREATE TABLE available_policies (customer_phone VARCHAR, policy_type_code VARCHAR)
SELECT customer_phone FROM available_policies WHERE policy_type_code = "Life Insurance"
### Context: CREATE TABLE available_policies (customer_phone VARCHAR, policy_type_code VARCHAR) ### Question: What are the customer phone numbers under the policy "Life Insurance"? ### Answer: SELECT customer_phone FROM available_policies WHERE policy_type_code = "Life Insurance"
Which policy type has the most records in the database?
CREATE TABLE available_policies (policy_type_code VARCHAR)
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1
### Context: CREATE TABLE available_policies (policy_type_code VARCHAR) ### Question: Which policy type has the most records in the database? ### Answer: SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1
What are all the customer phone numbers under the most popular policy type?
CREATE TABLE available_policies (customer_phone VARCHAR, policy_type_code VARCHAR)
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)
### Context: CREATE TABLE available_policies (customer_phone VARCHAR, policy_type_code VARCHAR) ### Question: What are all the customer phone numbers under the most popular policy type? ### Answer: 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)
Find the policy type used by more than 4 customers.
CREATE TABLE available_policies (policy_type_code VARCHAR)
SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING COUNT(*) > 4
### Context: CREATE TABLE available_policies (policy_type_code VARCHAR) ### Question: Find the policy type used by more than 4 customers. ### Answer: SELECT policy_type_code FROM available_policies GROUP BY policy_type_code HAVING COUNT(*) > 4
Find the total and average amount of settlements.
CREATE TABLE settlements (settlement_amount INTEGER)
SELECT SUM(settlement_amount), AVG(settlement_amount) FROM settlements
### Context: CREATE TABLE settlements (settlement_amount INTEGER) ### Question: Find the total and average amount of settlements. ### Answer: SELECT SUM(settlement_amount), AVG(settlement_amount) FROM settlements