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