Question: What is the id of the most recent order?

Context: CREATE TABLE orders (order_id VARCHAR, date_order_placed VARCHAR)

SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1


Question: what are the order id and customer id of the oldest order?

Context: CREATE TABLE orders (order_id VARCHAR, customer_id VARCHAR, date_order_placed VARCHAR)

SELECT order_id, customer_id FROM orders ORDER BY date_order_placed LIMIT 1


Question: Find the id of the order whose shipment tracking number is "3452".

Context: CREATE TABLE shipments (order_id VARCHAR, shipment_tracking_number VARCHAR)

SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452"


Question: Find the ids of all the order items whose product id is 11.

Context: CREATE TABLE order_items (order_item_id VARCHAR, product_id VARCHAR)

SELECT order_item_id FROM order_items WHERE product_id = 11


Question: List the name of all the distinct customers who have orders with status "Packing".

Context: CREATE TABLE orders (customer_id VARCHAR, order_status VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing"


Question: Find the details of all the distinct customers who have orders with status "On Road".

Context: CREATE TABLE orders (customer_id VARCHAR, order_status VARCHAR); CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR)

SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road"


Question: What is the name of the customer who has the most orders?

Context: CREATE TABLE orders (customer_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the customer id of the customer who has the most orders?

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE orders (customer_id VARCHAR)

SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Give me a list of id and status of orders which belong to the customer named "Jeramie".

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE orders (order_id VARCHAR, order_status VARCHAR, customer_id VARCHAR)

SELECT T2.order_id, T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"


Question: Find the dates of orders which belong to the customer named "Jeramie".

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE orders (date_order_placed VARCHAR, customer_id VARCHAR)

SELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"


Question: Give me the names of customers who have placed orders between 2009-01-01 and 2010-01-01.

Context: CREATE TABLE orders (customer_id VARCHAR, date_order_placed VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01"


Question: Give me a list of distinct product ids from orders placed between 1975-01-01 and 1976-01-01?

Context: CREATE TABLE order_items (product_id VARCHAR, order_id VARCHAR); CREATE TABLE orders (order_id VARCHAR, date_order_placed VARCHAR)

SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01"


Question: Find the names of the customers who have order status both "On Road" and "Shipped".

SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"


Question: Find the id of the customers who have order status both "On Road" and "Shipped".

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE orders (customer_id VARCHAR, order_status VARCHAR)

SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"


Question: When was the order placed whose shipment tracking number is 3452? Give me the date.

Context: CREATE TABLE shipments (order_id VARCHAR, shipment_tracking_number VARCHAR); CREATE TABLE orders (date_order_placed VARCHAR, order_id VARCHAR)

SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452


Question: What is the placement date of the order whose invoice number is 10?

Context: CREATE TABLE orders (date_order_placed VARCHAR, order_id VARCHAR); CREATE TABLE shipments (order_id VARCHAR, invoice_number VARCHAR)

SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10


Question: List the count and id of each product in all the orders.

Context: CREATE TABLE orders (order_id VARCHAR); CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE products (product_id VARCHAR)

SELECT COUNT(*), T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id


Question: List the name and count of each product in all orders.

Context: CREATE TABLE orders (order_id VARCHAR); CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR)

SELECT T3.product_name, COUNT(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id


Question: Find the ids of orders which are shipped after 2000-01-01.

Context: CREATE TABLE shipments (order_id VARCHAR, shipment_date INTEGER)

SELECT order_id FROM shipments WHERE shipment_date > "2000-01-01"


Question: Find the id of the order which is shipped most recently.

SELECT order_id FROM shipments WHERE shipment_date = (SELECT MAX(shipment_date) FROM shipments)


Question: List the names of all distinct products in alphabetical order.

Context: CREATE TABLE products (product_name VARCHAR)

SELECT DISTINCT product_name FROM products ORDER BY product_name


Question: List the ids of all distinct orders ordered by placed date.

Context: CREATE TABLE orders (order_id VARCHAR, date_order_placed VARCHAR)

SELECT DISTINCT order_id FROM orders ORDER BY date_order_placed


Question: What is the id of the order which has the most items?

Context: CREATE TABLE orders (order_id VARCHAR); CREATE TABLE order_items (order_id VARCHAR)

SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the invoice numbers which are created before 1989-09-03 or after 2007-12-25.

Context: CREATE TABLE invoices (invoice_number VARCHAR, invoice_date VARCHAR)

SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"


Question: Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25.

Context: CREATE TABLE invoices (invoice_details VARCHAR, invoice_date VARCHAR)

SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25"


Question: For each customer who has at least two orders, find the customer name and number of orders made.

Context: CREATE TABLE orders (customer_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

SELECT T2.customer_name, COUNT(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING COUNT(*) >= 2


Question: Find the name of the customers who have at most two orders.

SELECT T2.customer_name FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING COUNT(*) <= 2


Question: List the names of the customers who have once bought product "food".

Context: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE orders (customer_id VARCHAR, order_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE order_items (product_id VARCHAR, order_id VARCHAR)

SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING COUNT(*) >= 1


Question: List the names of customers who have once canceled the purchase of the product "food" (the item status is "Cancel").

Context: CREATE TABLE orders (customer_id VARCHAR, order_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR); CREATE TABLE order_items (product_id VARCHAR, order_item_status VARCHAR, order_id VARCHAR)

SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T3.order_item_status = "Cancel" AND T4.product_name = "food" GROUP BY T1.customer_id HAVING COUNT(*) >= 1


Question: How many architects are female?

Context: CREATE TABLE architect (gender VARCHAR)

SELECT COUNT(*) FROM architect WHERE gender = 'female'


Question: List the name, nationality and id of all male architects ordered by their names lexicographically.

Context: CREATE TABLE architect (name VARCHAR, nationality VARCHAR, id VARCHAR, gender VARCHAR)

SELECT name, nationality, id FROM architect WHERE gender = 'male' ORDER BY name


Question: What is the maximum length in meters for the bridges and what are the architects' names?

Context: CREATE TABLE architect (name VARCHAR, id VARCHAR); CREATE TABLE bridge (length_meters INTEGER, architect_id VARCHAR)

SELECT MAX(T1.length_meters), T2.name FROM bridge AS T1 JOIN architect AS T2 ON T1.architect_id = T2.id


Question: What is the average length in feet of the bridges?

Context: CREATE TABLE bridge (length_feet INTEGER)


Question: What are the names and year of construction for the mills of 'Grondzeiler' type?

Context: CREATE TABLE mill (name VARCHAR, built_year VARCHAR, TYPE VARCHAR)

SELECT name, built_year FROM mill WHERE TYPE = 'Grondzeiler'


Question: What are the distinct names and nationalities of the architects who have ever built a mill?

Context: CREATE TABLE mill (Id VARCHAR); CREATE TABLE architect (name VARCHAR, nationality VARCHAR, id VARCHAR)

SELECT DISTINCT T1.name, T1.nationality FROM architect AS T1 JOIN mill AS t2 ON T1.id = T2.architect_id


Question: What are the names of the mills which are not located in 'Donceel'?

Context: CREATE TABLE mill (name VARCHAR, LOCATION VARCHAR)

SELECT name FROM mill WHERE LOCATION <> 'Donceel'


Question: What are the distinct types of mills that are built by American or Canadian architects?

Context: CREATE TABLE architect (Id VARCHAR); CREATE TABLE mill (type VARCHAR, architect_id VARCHAR)

SELECT DISTINCT T1.type FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id = T2.id WHERE T2.nationality = 'American' OR T2.nationality = 'Canadian'


Question: What are the ids and names of the architects who built at least 3 bridges ?

Context: CREATE TABLE architect (id VARCHAR, name VARCHAR); CREATE TABLE bridge (architect_id VARCHAR)

SELECT T1.id, T1.name FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING COUNT(*) >= 3


Question: What is the id, name and nationality of the architect who built most mills?

Context: CREATE TABLE architect (id VARCHAR, name VARCHAR, nationality VARCHAR); CREATE TABLE mill (architect_id VARCHAR)

SELECT T1.id, T1.name, T1.nationality FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the ids, names and genders of the architects who built two bridges or one mill?

Context: CREATE TABLE mill (architect_id VARCHAR); CREATE TABLE architect (id VARCHAR, name VARCHAR, gender VARCHAR); CREATE TABLE bridge (architect_id VARCHAR)

SELECT T1.id, T1.name, T1.gender FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING COUNT(*) = 2 UNION SELECT T1.id, T1.name, T1.gender FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING COUNT(*) = 1


Question: What is the location of the bridge named 'Kolob Arch' or 'Rainbow Bridge'?

Context: CREATE TABLE bridge (LOCATION VARCHAR, name VARCHAR)

SELECT LOCATION FROM bridge WHERE name = 'Kolob Arch' OR name = 'Rainbow Bridge'


Question: Which of the mill names contains the french word 'Moulin'?

Context: CREATE TABLE mill (name VARCHAR)

SELECT name FROM mill WHERE name LIKE '%Moulin%'


Question: What are the distinct name of the mills built by the architects who have also built a bridge longer than 80 meters?

Context: CREATE TABLE architect (Id VARCHAR); CREATE TABLE mill (name VARCHAR, architect_id VARCHAR); CREATE TABLE bridge (architect_id VARCHAR, length_meters INTEGER)

SELECT DISTINCT T1.name FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id = T2.id JOIN bridge AS T3 ON T3.architect_id = T2.id WHERE T3.length_meters > 80


Question: What is the most common mill type, and how many are there?

Context: CREATE TABLE mill (TYPE VARCHAR)

SELECT TYPE, COUNT(*) FROM mill GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: How many architects haven't built a mill before year 1850?

Context: CREATE TABLE mill (id VARCHAR, architect_id VARCHAR, built_year INTEGER); CREATE TABLE architect (id VARCHAR, architect_id VARCHAR, built_year INTEGER)

SELECT COUNT(*) FROM architect WHERE NOT id IN (SELECT architect_id FROM mill WHERE built_year < 1850)


Question: show the name of all bridges that was designed by american archtect, and sort the result by the bridge feet length.

Context: CREATE TABLE bridge (name VARCHAR, architect_id VARCHAR, length_feet VARCHAR); CREATE TABLE architect (id VARCHAR, nationality VARCHAR)

SELECT t1.name FROM bridge AS t1 JOIN architect AS t2 ON t1.architect_id = t2.id WHERE t2.nationality = 'American' ORDER BY t1.length_feet


Question: How many book clubs are there?

Context: CREATE TABLE book_club (Id VARCHAR)


Question: show the titles, and authors or editors for all books made after the year 1989.

Context: CREATE TABLE book_club (book_title VARCHAR, author_or_editor VARCHAR, YEAR INTEGER)

SELECT book_title, author_or_editor FROM book_club WHERE YEAR > 1989


Question: Show all distinct publishers for books.

Context: CREATE TABLE book_club (publisher VARCHAR)

SELECT DISTINCT publisher FROM book_club


Question: Show the years, book titles, and publishers for all books, in descending order by year.

Context: CREATE TABLE book_club (YEAR VARCHAR, book_title VARCHAR, publisher VARCHAR)

SELECT YEAR, book_title, publisher FROM book_club ORDER BY YEAR DESC


Question: Show all publishers and the number of books for each publisher.

SELECT publisher, COUNT(*) FROM book_club GROUP BY publisher


Question: What is the publisher with most number of books?

SELECT publisher FROM book_club GROUP BY publisher ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all book categories and the number of books in each category.

Context: CREATE TABLE book_club (category VARCHAR)

SELECT category, COUNT(*) FROM book_club GROUP BY category


Question: List categories that have at least two books after year 1989.

Context: CREATE TABLE book_club (category VARCHAR, YEAR INTEGER)

SELECT category FROM book_club WHERE YEAR > 1989 GROUP BY category HAVING COUNT(*) >= 2


Question: Show publishers with a book published in 1989 and a book in 1990.

Context: CREATE TABLE book_club (publisher VARCHAR, YEAR VARCHAR)

SELECT publisher FROM book_club WHERE YEAR = 1989 INTERSECT SELECT publisher FROM book_club WHERE YEAR = 1990


Question: Show all publishers which do not have a book in 1989.

SELECT publisher FROM book_club EXCEPT SELECT publisher FROM book_club WHERE YEAR = 1989


Question: Show all movie titles, years, and directors, ordered by budget.

Context: CREATE TABLE movie (title VARCHAR, YEAR VARCHAR, director VARCHAR, budget_million VARCHAR)

SELECT title, YEAR, director FROM movie ORDER BY budget_million


Question: How many movie directors are there?

Context: CREATE TABLE movie (director VARCHAR)

SELECT COUNT(DISTINCT director) FROM movie


Question: What is the title and director for the movie with highest worldwide gross in the year 2000 or before?

Context: CREATE TABLE movie (title VARCHAR, director VARCHAR, YEAR VARCHAR, gross_worldwide VARCHAR)

SELECT title, director FROM movie WHERE YEAR <= 2000 ORDER BY gross_worldwide DESC LIMIT 1


Question: Show all director names who have a movie in both year 1999 and 2000.

Context: CREATE TABLE movie (director VARCHAR, YEAR VARCHAR)

SELECT director FROM movie WHERE YEAR = 2000 INTERSECT SELECT director FROM movie WHERE YEAR = 1999


Question: Show all director names who have a movie in the year 1999 or 2000.

SELECT director FROM movie WHERE YEAR = 1999 OR YEAR = 2000


Question: What is the average, maximum, and minimum budget for all movies before 2000.

Context: CREATE TABLE movie (budget_million INTEGER, YEAR INTEGER)

SELECT AVG(budget_million), MAX(budget_million), MIN(budget_million) FROM movie WHERE YEAR < 2000


Question: List all company names with a book published by Alyson.

Context: CREATE TABLE culture_company (company_name VARCHAR, book_club_id VARCHAR); CREATE TABLE book_club (book_club_id VARCHAR, publisher VARCHAR)

SELECT T1.company_name FROM culture_company AS T1 JOIN book_club AS T2 ON T1.book_club_id = T2.book_club_id WHERE T2.publisher = 'Alyson'


Question: Show the movie titles and book titles for all companies in China.

Context: CREATE TABLE movie (title VARCHAR, movie_id VARCHAR); CREATE TABLE culture_company (movie_id VARCHAR, book_club_id VARCHAR, incorporated_in VARCHAR); CREATE TABLE book_club (book_title VARCHAR, book_club_id VARCHAR)

SELECT T1.title, T3.book_title FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id = T2.movie_id JOIN book_club AS T3 ON T3.book_club_id = T2.book_club_id WHERE T2.incorporated_in = 'China'


Question: Show all company names with a movie directed in year 1999.

Context: CREATE TABLE movie (movie_id VARCHAR, year VARCHAR); CREATE TABLE culture_company (company_name VARCHAR, movie_id VARCHAR)

SELECT T2.company_name FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id = T2.movie_id WHERE T1.year = 1999


Question: How many singers do we have?

Context: CREATE TABLE singer (Id VARCHAR)


Question: Show name, country, age for all singers ordered by age from the oldest to the youngest.

Context: CREATE TABLE singer (name VARCHAR, country VARCHAR, age VARCHAR)

SELECT name, country, age FROM singer ORDER BY age DESC


Question: What is the average, minimum, and maximum age of all singers from France?

Context: CREATE TABLE singer (age INTEGER, country VARCHAR)

SELECT AVG(age), MIN(age), MAX(age) FROM singer WHERE country = 'France'


Question: Show the name and the release year of the song by the youngest singer.

Context: CREATE TABLE singer (song_name VARCHAR, song_release_year VARCHAR, age VARCHAR)

SELECT song_name, song_release_year FROM singer ORDER BY age LIMIT 1


Question: What are all distinct countries where singers above age 20 are from?

Context: CREATE TABLE singer (country VARCHAR, age INTEGER)

SELECT DISTINCT country FROM singer WHERE age > 20


Question: Show all countries and the number of singers in each country.

Context: CREATE TABLE singer (country VARCHAR)

SELECT country, COUNT(*) FROM singer GROUP BY country


Question: List all song names by singers above the average age.

Context: CREATE TABLE singer (song_name VARCHAR, age INTEGER)

SELECT song_name FROM singer WHERE age > (SELECT AVG(age) FROM singer)


Question: Show location and name for all stadiums with a capacity between 5000 and 10000.

Context: CREATE TABLE stadium (LOCATION VARCHAR, name VARCHAR, capacity INTEGER)

SELECT LOCATION, name FROM stadium WHERE capacity BETWEEN 5000 AND 10000


Question: What is the maximum capacity and the average of all stadiums ?

Context: CREATE TABLE stadium (average VARCHAR, capacity INTEGER)

SELECT MAX(capacity), average FROM stadium


Question: What is the average and maximum capacities for all stadiums ?

Context: CREATE TABLE stadium (capacity INTEGER)

SELECT AVG(capacity), MAX(capacity) FROM stadium


Question: What is the name and capacity for the stadium with highest average attendance?

Context: CREATE TABLE stadium (name VARCHAR, capacity VARCHAR, average VARCHAR)

SELECT name, capacity FROM stadium ORDER BY average DESC LIMIT 1


Question: How many concerts are there in year 2014 or 2015?

Context: CREATE TABLE concert (YEAR VARCHAR)

SELECT COUNT(*) FROM concert WHERE YEAR = 2014 OR YEAR = 2015


Question: Show the stadium name and the number of concerts in each stadium.

Context: CREATE TABLE stadium (name VARCHAR, stadium_id VARCHAR); CREATE TABLE concert (stadium_id VARCHAR)

SELECT T2.name, COUNT(*) FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id GROUP BY T1.stadium_id


Question: Show the stadium name and capacity with most number of concerts in year 2014 or after.

Context: CREATE TABLE stadium (name VARCHAR, capacity VARCHAR, stadium_id VARCHAR); CREATE TABLE concert (stadium_id VARCHAR, year VARCHAR)

SELECT T2.name, T2.capacity FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year >= 2014 GROUP BY T2.stadium_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the name and capacity of the stadium with the most concerts after 2013 ?

Context: CREATE TABLE concert (stadium_id VARCHAR, year INTEGER); CREATE TABLE stadium (name VARCHAR, capacity VARCHAR, stadium_id VARCHAR)

SELECT t2.name, t2.capacity FROM concert AS t1 JOIN stadium AS t2 ON t1.stadium_id = t2.stadium_id WHERE t1.year > 2013 GROUP BY t2.stadium_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Which year has most number of concerts?

Context: CREATE TABLE concert (YEAR VARCHAR)

SELECT YEAR FROM concert GROUP BY YEAR ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the stadium names without any concert.

Context: CREATE TABLE stadium (name VARCHAR, stadium_id VARCHAR); CREATE TABLE concert (name VARCHAR, stadium_id VARCHAR)

SELECT name FROM stadium WHERE NOT stadium_id IN (SELECT stadium_id FROM concert)


Question: Show countries where a singer above age 40 and a singer below 30 are from.

SELECT country FROM singer WHERE age > 40 INTERSECT SELECT country FROM singer WHERE age < 30


Question: Show names for all stadiums except for stadiums having a concert in year 2014.

Context: CREATE TABLE stadium (name VARCHAR, stadium_id VARCHAR); CREATE TABLE concert (stadium_id VARCHAR, year VARCHAR); CREATE TABLE stadium (name VARCHAR)

SELECT name FROM stadium EXCEPT SELECT T2.name FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year = 2014


Question: Show the name and theme for all concerts and the number of singers in each concert.

Context: CREATE TABLE singer_in_concert (concert_id VARCHAR); CREATE TABLE concert (concert_name VARCHAR, theme VARCHAR, concert_id VARCHAR)

SELECT T2.concert_name, T2.theme, COUNT(*) FROM singer_in_concert AS T1 JOIN concert AS T2 ON T1.concert_id = T2.concert_id GROUP BY T2.concert_id


Question: What are the names , themes , and number of singers for every concert ?

SELECT t2.concert_name, t2.theme, COUNT(*) FROM singer_in_concert AS t1 JOIN concert AS t2 ON t1.concert_id = t2.concert_id GROUP BY t2.concert_id


Question: List singer names and number of concerts for each singer.

Context: CREATE TABLE singer_in_concert (singer_id VARCHAR); CREATE TABLE singer (name VARCHAR, singer_id VARCHAR)

SELECT T2.name, COUNT(*) FROM singer_in_concert AS T1 JOIN singer AS T2 ON T1.singer_id = T2.singer_id GROUP BY T2.singer_id


Question: List all singer names in concerts in year 2014.

Context: CREATE TABLE singer_in_concert (singer_id VARCHAR, concert_id VARCHAR); CREATE TABLE concert (concert_id VARCHAR, year VARCHAR); CREATE TABLE singer (name VARCHAR, singer_id VARCHAR)

SELECT T2.name FROM singer_in_concert AS T1 JOIN singer AS T2 ON T1.singer_id = T2.singer_id JOIN concert AS T3 ON T1.concert_id = T3.concert_id WHERE T3.year = 2014


Question: what is the name and nation of the singer who have a song having 'Hey' in its name?

Context: CREATE TABLE singer (name VARCHAR, country VARCHAR, song_name VARCHAR)

SELECT name, country FROM singer WHERE song_name LIKE '%Hey%'


Question: Find the name and location of the stadiums which some concerts happened in the years of both 2014 and 2015.

Context: CREATE TABLE stadium (name VARCHAR, location VARCHAR, stadium_id VARCHAR); CREATE TABLE concert (stadium_id VARCHAR, Year VARCHAR)

SELECT T2.name, T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name, T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015


Question: Find the number of concerts happened in the stadium with the highest capacity .

Context: CREATE TABLE concert (stadium_id VARCHAR, capacity VARCHAR); CREATE TABLE stadium (stadium_id VARCHAR, capacity VARCHAR)

SELECT COUNT(*) FROM concert WHERE stadium_id = (SELECT stadium_id FROM stadium ORDER BY capacity DESC LIMIT 1)


Question: Find the number of pets whose weight is heavier than 10.

Context: CREATE TABLE pets (weight INTEGER)

SELECT COUNT(*) FROM pets WHERE weight > 10


Question: Find the weight of the youngest dog.

Context: CREATE TABLE pets (weight VARCHAR, pet_age VARCHAR)

SELECT weight FROM pets ORDER BY pet_age LIMIT 1


Question: Find the maximum weight for each type of pet. List the maximum weight and pet type.

Context: CREATE TABLE pets (petType VARCHAR, weight INTEGER)

SELECT MAX(weight), petType FROM pets GROUP BY petType


Question: Find number of pets owned by students who are older than 20.

Context: CREATE TABLE student (stuid VARCHAR, age INTEGER); CREATE TABLE has_pet (stuid VARCHAR)

SELECT COUNT(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid WHERE T1.age > 20


Question: Find the number of dog pets that are raised by female students (with sex F).

Context: CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE pets (petid VARCHAR, pettype VARCHAR); CREATE TABLE student (stuid VARCHAR, sex VARCHAR)

SELECT COUNT(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T2.petid = T3.petid WHERE T1.sex = 'F' AND T3.pettype = 'dog'


Question: Find the number of distinct type of pets.

Context: CREATE TABLE pets (pettype VARCHAR)

SELECT COUNT(DISTINCT pettype) FROM pets


Question: Find the first name of students who have cat or dog pet.

Context: CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE student (Fname VARCHAR, stuid VARCHAR); CREATE TABLE pets (petid VARCHAR, pettype VARCHAR)

SELECT DISTINCT T1.Fname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat' OR T3.pettype = 'dog'


Question: Find the first name of students who have both cat and dog pets .

Context: CREATE TABLE student (fname VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE pets (petid VARCHAR, pettype VARCHAR)

SELECT t1.fname FROM student AS t1 JOIN has_pet AS t2 ON t1.stuid = t2.stuid JOIN pets AS t3 ON t3.petid = t2.petid WHERE t3.pettype = 'cat' INTERSECT SELECT t1.fname FROM student AS t1 JOIN has_pet AS t2 ON t1.stuid = t2.stuid JOIN pets AS t3 ON t3.petid = t2.petid WHERE t3.pettype = 'dog'


Question: What are the students' first names who have both cats and dogs as pets?

SELECT T1.Fname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat' INTERSECT SELECT T1.Fname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'dog'


Question: Find the major and age of students who do not have a cat pet.

Context: CREATE TABLE student (stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE pets (petid VARCHAR, pettype VARCHAR); CREATE TABLE student (major VARCHAR, age VARCHAR, stuid VARCHAR)

SELECT major, age FROM student WHERE NOT stuid IN (SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat')


Question: Find the id of students who do not have a cat pet.

Context: CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE pets (petid VARCHAR, pettype VARCHAR); CREATE TABLE student (stuid VARCHAR)

SELECT stuid FROM student EXCEPT SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat'


Question: Find the first name and age of students who have a dog but do not have a cat as a pet.

Context: CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE student (fname VARCHAR, age VARCHAR, stuid VARCHAR); CREATE TABLE pets (petid VARCHAR, pettype VARCHAR)

SELECT T1.fname, T1.age FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'dog' AND NOT T1.stuid IN (SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat')


Question: Find the type and weight of the youngest pet.

Context: CREATE TABLE pets (pettype VARCHAR, weight VARCHAR, pet_age VARCHAR)

SELECT pettype, weight FROM pets ORDER BY pet_age LIMIT 1


Question: Find the id and weight of all pets whose age is older than 1.

Context: CREATE TABLE pets (petid VARCHAR, weight VARCHAR, pet_age INTEGER)

SELECT petid, weight FROM pets WHERE pet_age > 1


Question: Find the average and maximum age for each type of pet.

Context: CREATE TABLE pets (pettype VARCHAR, pet_age INTEGER)

SELECT AVG(pet_age), MAX(pet_age), pettype FROM pets GROUP BY pettype


Question: Find the average weight for each pet type.

Context: CREATE TABLE pets (pettype VARCHAR, weight INTEGER)

SELECT AVG(weight), pettype FROM pets GROUP BY pettype


Question: Find the first name and age of students who have a pet.

Context: CREATE TABLE student (fname VARCHAR, age VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR)

SELECT DISTINCT T1.fname, T1.age FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid


Question: Find the id of the pet owned by student whose last name is ‘Smith’.

Context: CREATE TABLE has_pet (petid VARCHAR, stuid VARCHAR); CREATE TABLE student (stuid VARCHAR, Lname VARCHAR)

SELECT T2.petid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid WHERE T1.Lname = 'Smith'


Question: Find the number of pets for each student who has any pet and student id.

Context: CREATE TABLE has_pet (stuid VARCHAR); CREATE TABLE student (stuid VARCHAR)

SELECT COUNT(*), T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid GROUP BY T1.stuid


Question: For students who have pets , how many pets does each student have ? list their ids instead of names .

SELECT COUNT(*), t1.stuid FROM student AS t1 JOIN has_pet AS t2 ON t1.stuid = t2.stuid GROUP BY t1.stuid


Question: Find the first name and gender of student who have more than one pet.

Context: CREATE TABLE student (fname VARCHAR, sex VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR)

SELECT T1.fname, T1.sex FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid GROUP BY T1.stuid HAVING COUNT(*) > 1


Question: Find the last name of the student who has a cat that is age 3.

Context: CREATE TABLE student (lname VARCHAR, stuid VARCHAR); CREATE TABLE has_pet (stuid VARCHAR, petid VARCHAR); CREATE TABLE pets (petid VARCHAR, pet_age VARCHAR, pettype VARCHAR)

SELECT T1.lname FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pet_age = 3 AND T3.pettype = 'cat'


Question: Find the average age of students who do not have any pet .

Context: CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE has_pet (age INTEGER, stuid VARCHAR)

SELECT AVG(age) FROM student WHERE NOT stuid IN (SELECT stuid FROM has_pet)


Question: How many continents are there?

Context: CREATE TABLE CONTINENTS (Id VARCHAR)


Question: How many countries does each continent have? List the continent id, continent name and the number of countries.

Context: CREATE TABLE COUNTRIES (Continent VARCHAR); CREATE TABLE CONTINENTS (ContId VARCHAR, Continent VARCHAR)

SELECT T1.ContId, T1.Continent, COUNT(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.Continent GROUP BY T1.ContId


Question: How many countries are listed?

Context: CREATE TABLE COUNTRIES (Id VARCHAR)


Question: How many models does each car maker produce? List maker full name, id and the number.

Context: CREATE TABLE MODEL_LIST (Maker VARCHAR); CREATE TABLE CAR_MAKERS (FullName VARCHAR, Id VARCHAR)

SELECT T1.FullName, T1.Id, COUNT(*) FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id


Question: Which model of the car has the minimum horsepower?

Context: CREATE TABLE CARS_DATA (Id VARCHAR, horsepower VARCHAR); CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR)

SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id ORDER BY T2.horsepower LIMIT 1


Question: Find the model of the car whose weight is below the average weight.

Context: CREATE TABLE CARS_DATA (Id VARCHAR, Weight INTEGER); CREATE TABLE CARS_DATA (Weight INTEGER); CREATE TABLE CAR_NAMES (model VARCHAR, MakeId VARCHAR)

SELECT T1.model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.Weight < (SELECT AVG(Weight) FROM CARS_DATA)


Question: Find the name of the makers that produced some cars in the year of 1970?

Context: CREATE TABLE MODEL_LIST (Maker VARCHAR, model VARCHAR); CREATE TABLE CAR_MAKERS (Maker VARCHAR, Id VARCHAR); CREATE TABLE CARS_DATA (id VARCHAR, year VARCHAR); CREATE TABLE CAR_NAMES (model VARCHAR, MakeId VARCHAR)

SELECT DISTINCT T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model JOIN CARS_DATA AS T4 ON T3.MakeId = T4.id WHERE T4.year = '1970'


Question: Find the make and production time of the cars that were produced in the earliest year?

Context: CREATE TABLE CARS_DATA (YEAR INTEGER); CREATE TABLE CAR_NAMES (Make VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Year VARCHAR, Id VARCHAR)

SELECT T2.Make, T1.Year FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T1.Year = (SELECT MIN(YEAR) FROM CARS_DATA)


Question: Which distinct car models are the produced after 1980?

Context: CREATE TABLE CARS_DATA (id VARCHAR, year INTEGER); CREATE TABLE MODEL_LIST (model VARCHAR); CREATE TABLE CAR_NAMES (model VARCHAR, MakeId VARCHAR)

SELECT DISTINCT T1.model FROM MODEL_LIST AS T1 JOIN CAR_NAMES AS T2 ON T1.model = T2.model JOIN CARS_DATA AS T3 ON T2.MakeId = T3.id WHERE T3.year > 1980


Question: How many car makers are there in each continents? List the continent name and the count.

Context: CREATE TABLE COUNTRIES (continent VARCHAR, CountryId VARCHAR); CREATE TABLE CONTINENTS (Continent VARCHAR, ContId VARCHAR); CREATE TABLE car_makers (Country VARCHAR)

SELECT T1.Continent, COUNT(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.continent JOIN car_makers AS T3 ON T2.CountryId = T3.Country GROUP BY T1.Continent


Question: Which of the countries has the most car makers? List the country name.

Context: CREATE TABLE CAR_MAKERS (Country VARCHAR); CREATE TABLE COUNTRIES (CountryName VARCHAR, CountryId VARCHAR)

SELECT T2.CountryName FROM CAR_MAKERS AS T1 JOIN COUNTRIES AS T2 ON T1.Country = T2.CountryId GROUP BY T1.Country ORDER BY COUNT(*) DESC LIMIT 1


Question: How many car models are produced by each maker ? Only list the count and the maker full name .

Context: CREATE TABLE model_list (maker VARCHAR); CREATE TABLE car_makers (fullname VARCHAR, id VARCHAR)

SELECT COUNT(*), t2.fullname FROM model_list AS t1 JOIN car_makers AS t2 ON t1.maker = t2.id GROUP BY t2.id


Question: What is the number of car models that are produced by each maker and what is the id and full name of each maker?

Context: CREATE TABLE CAR_MAKERS (FullName VARCHAR, id VARCHAR, Id VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR)

SELECT COUNT(*), T2.FullName, T2.id FROM MODEL_LIST AS T1 JOIN CAR_MAKERS AS T2 ON T1.Maker = T2.Id GROUP BY T2.id


Question: What is the accelerate of the car make amc hornet sportabout (sw)?

Context: CREATE TABLE CARS_DATA (Accelerate VARCHAR, Id VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Make VARCHAR)

SELECT T1.Accelerate FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T2.Make = 'amc hornet sportabout (sw)'


Question: How many car makers are there in france?

Context: CREATE TABLE COUNTRIES (CountryId VARCHAR, CountryName VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR)

SELECT COUNT(*) FROM CAR_MAKERS AS T1 JOIN COUNTRIES AS T2 ON T1.Country = T2.CountryId WHERE T2.CountryName = 'france'


Question: How many car models are produced in the usa?

Context: CREATE TABLE CAR_MAKERS (Id VARCHAR, Country VARCHAR); CREATE TABLE COUNTRIES (CountryId VARCHAR, CountryName VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR)

SELECT COUNT(*) FROM MODEL_LIST AS T1 JOIN CAR_MAKERS AS T2 ON T1.Maker = T2.Id JOIN COUNTRIES AS T3 ON T2.Country = T3.CountryId WHERE T3.CountryName = 'usa'


Question: What is the average miles per gallon(mpg) of the cars with 4 cylinders?

Context: CREATE TABLE CARS_DATA (mpg INTEGER, Cylinders VARCHAR)

SELECT AVG(mpg) FROM CARS_DATA WHERE Cylinders = 4


Question: What is the smallest weight of the car produced with 8 cylinders on 1974 ?

Context: CREATE TABLE cars_data (weight INTEGER, cylinders VARCHAR, year VARCHAR)

SELECT MIN(weight) FROM cars_data WHERE cylinders = 8 AND year = 1974


Question: What are all the makers and models?

Context: CREATE TABLE MODEL_LIST (Maker VARCHAR, Model VARCHAR)


Question: What are the countries having at least one car maker? List name and id.

SELECT T1.CountryName, T1.CountryId FROM COUNTRIES AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country GROUP BY T1.CountryId HAVING COUNT(*) >= 1


Question: What is the number of the cars with horsepower more than 150?

Context: CREATE TABLE CARS_DATA (horsepower INTEGER)

SELECT COUNT(*) FROM CARS_DATA WHERE horsepower > 150


Question: What is the average weight of cars each year?

Context: CREATE TABLE CARS_DATA (YEAR VARCHAR, Weight INTEGER)

SELECT AVG(Weight), YEAR FROM CARS_DATA GROUP BY YEAR


Question: Which countries in europe have at least 3 car manufacturers?

Context: CREATE TABLE COUNTRIES (CountryName VARCHAR, Continent VARCHAR, CountryId VARCHAR); CREATE TABLE CONTINENTS (ContId VARCHAR, Continent VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR)

SELECT T1.CountryName FROM COUNTRIES AS T1 JOIN CONTINENTS AS T2 ON T1.Continent = T2.ContId JOIN CAR_MAKERS AS T3 ON T1.CountryId = T3.Country WHERE T2.Continent = 'europe' GROUP BY T1.CountryName HAVING COUNT(*) >= 3


Question: What is the maximum horsepower and the make of the car models with 3 cylinders?

Context: CREATE TABLE CAR_NAMES (Make VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (horsepower VARCHAR, Id VARCHAR, cylinders VARCHAR)

SELECT T2.horsepower, T1.Make FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.cylinders = 3 ORDER BY T2.horsepower DESC LIMIT 1


Question: Which model saves the most gasoline? That is to say, have the maximum miles per gallon.

Context: CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, mpg VARCHAR)

SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id ORDER BY T2.mpg DESC LIMIT 1


Question: What is the car model with the highest mpg ?

Context: CREATE TABLE cars_data (id VARCHAR, mpg VARCHAR); CREATE TABLE car_names (model VARCHAR, makeid VARCHAR)

SELECT t1.model FROM car_names AS t1 JOIN cars_data AS t2 ON t1.makeid = t2.id ORDER BY t2.mpg DESC LIMIT 1


Question: What is the average horsepower of the cars before 1980?

Context: CREATE TABLE CARS_DATA (horsepower INTEGER, YEAR INTEGER)

SELECT AVG(horsepower) FROM CARS_DATA WHERE YEAR < 1980


Question: What is the average horsepower for all cars produced before 1980 ?

Context: CREATE TABLE cars_data (horsepower INTEGER, year INTEGER)

SELECT AVG(horsepower) FROM cars_data WHERE year < 1980


Question: What is the average edispl of the cars of model volvo?

Context: CREATE TABLE CARS_DATA (edispl INTEGER, Id VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Model VARCHAR)

SELECT AVG(T2.edispl) FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T1.Model = 'volvo'


Question: What is the maximum accelerate for different number of cylinders?

Context: CREATE TABLE CARS_DATA (Cylinders VARCHAR, Accelerate INTEGER)

SELECT MAX(Accelerate), Cylinders FROM CARS_DATA GROUP BY Cylinders


Question: Which model has the most version(make) of cars?

Context: CREATE TABLE CAR_NAMES (Model VARCHAR)

SELECT Model FROM CAR_NAMES GROUP BY Model ORDER BY COUNT(*) DESC LIMIT 1


Question: How many cars have more than 4 cylinders?

Context: CREATE TABLE CARS_DATA (Cylinders INTEGER)

SELECT COUNT(*) FROM CARS_DATA WHERE Cylinders > 4


Question: how many cars were produced in 1980?

Context: CREATE TABLE CARS_DATA (YEAR VARCHAR)

SELECT COUNT(*) FROM CARS_DATA WHERE YEAR = 1980


Question: How many car models were produced by the maker with full name American Motor Company?

Context: CREATE TABLE CAR_MAKERS (Id VARCHAR, FullName VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR)

SELECT COUNT(*) FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker WHERE T1.FullName = 'American Motor Company'


Question: Which makers designed more than 3 car models? List full name and the id.

Context: CREATE TABLE MODEL_LIST (Maker VARCHAR); CREATE TABLE CAR_MAKERS (FullName VARCHAR, Id VARCHAR)

SELECT T1.FullName, T1.Id FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING COUNT(*) > 3


Question: Which distinctive models are produced by maker with the full name General Motors or weighing more than 3500?

Context: CREATE TABLE MODEL_LIST (Model VARCHAR, Maker VARCHAR); CREATE TABLE CAR_MAKERS (Id VARCHAR, FullName VARCHAR); CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, weight VARCHAR)

SELECT DISTINCT T2.Model FROM CAR_NAMES AS T1 JOIN MODEL_LIST AS T2 ON T1.Model = T2.Model JOIN CAR_MAKERS AS T3 ON T2.Maker = T3.Id JOIN CARS_DATA AS T4 ON T1.MakeId = T4.Id WHERE T3.FullName = 'General Motors' OR T4.weight > 3500


Question: In which years cars were produced weighing no less than 3000 and no more than 4000 ?

Context: CREATE TABLE cars_data (year VARCHAR, weight INTEGER)

SELECT DISTINCT year FROM cars_data WHERE weight BETWEEN 3000 AND 4000


Question: What is the horsepower of the car with the largest accelerate?

Context: CREATE TABLE CARS_DATA (horsepower VARCHAR, accelerate VARCHAR)

SELECT T1.horsepower FROM CARS_DATA AS T1 ORDER BY T1.accelerate DESC LIMIT 1


Question: For model volvo, how many cylinders does the car with the least accelerate have?

Context: CREATE TABLE CARS_DATA (cylinders VARCHAR, Id VARCHAR, accelerate VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Model VARCHAR)

SELECT T1.cylinders FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T2.Model = 'volvo' ORDER BY T1.accelerate LIMIT 1


Question: How many cars have a larger accelerate than the car with the largest horsepower?

Context: CREATE TABLE CARS_DATA (Accelerate INTEGER, Horsepower VARCHAR)

SELECT COUNT(*) FROM CARS_DATA WHERE Accelerate > (SELECT Accelerate FROM CARS_DATA ORDER BY Horsepower DESC LIMIT 1)


Question: How many countries has more than 2 car makers ?

Context: CREATE TABLE car_makers (country VARCHAR); CREATE TABLE countries (countryid VARCHAR)

SELECT COUNT(*) FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country GROUP BY t1.countryid HAVING COUNT(*) > 2


Question: How many cars has over 6 cylinders?

SELECT COUNT(*) FROM CARS_DATA WHERE Cylinders > 6


Question: For the cars with 4 cylinders, which model has the largest horsepower?

Context: CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, Cylinders VARCHAR, horsepower VARCHAR)

SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id WHERE T2.Cylinders = 4 ORDER BY T2.horsepower DESC LIMIT 1


Question: Among the cars with more than lowest horsepower, which ones do not have more than 3 cylinders? List the car makeid and make name.

Context: CREATE TABLE CARS_DATA (Id VARCHAR, Horsepower INTEGER, Cylinders VARCHAR); CREATE TABLE CAR_NAMES (MakeId VARCHAR, Make VARCHAR); CREATE TABLE CARS_DATA (Horsepower INTEGER)

SELECT T2.MakeId, T2.Make FROM CARS_DATA AS T1 JOIN CAR_NAMES AS T2 ON T1.Id = T2.MakeId WHERE T1.Horsepower > (SELECT MIN(Horsepower) FROM CARS_DATA) AND T1.Cylinders <= 3


Question: Among the cars that do not have the minimum horsepower , what are the make ids and names of all those with less than 4 cylinders ?

Context: CREATE TABLE cars_data (horsepower INTEGER); CREATE TABLE car_names (makeid VARCHAR, make VARCHAR); CREATE TABLE cars_data (id VARCHAR, horsepower INTEGER, cylinders VARCHAR)

SELECT t2.makeid, t2.make FROM cars_data AS t1 JOIN car_names AS t2 ON t1.id = t2.makeid WHERE t1.horsepower > (SELECT MIN(horsepower) FROM cars_data) AND t1.cylinders < 4


Question: What is the maximum miles per gallon of the car with 8 cylinders or produced before 1980 ?

Context: CREATE TABLE cars_data (mpg INTEGER, cylinders VARCHAR, year VARCHAR)

SELECT MAX(mpg) FROM cars_data WHERE cylinders = 8 OR year < 1980


Question: Which models are lighter than 3500 but not built by the 'Ford Motor Company'?

Context: CREATE TABLE CAR_MAKERS (Id VARCHAR, FullName VARCHAR); CREATE TABLE MODEL_LIST (model VARCHAR, Model VARCHAR, Maker VARCHAR); CREATE TABLE CARS_DATA (Id VARCHAR, weight VARCHAR); CREATE TABLE CAR_NAMES (Model VARCHAR, MakeId VARCHAR)

SELECT DISTINCT T1.model FROM MODEL_LIST AS T1 JOIN CAR_NAMES AS T2 ON T1.Model = T2.Model JOIN CARS_DATA AS T3 ON T2.MakeId = T3.Id JOIN CAR_MAKERS AS T4 ON T1.Maker = T4.Id WHERE T3.weight < 3500 AND T4.FullName <> 'Ford Motor Company'


Question: What are the name of the countries where there is not a single car maker?

Context: CREATE TABLE countries (CountryName VARCHAR, countryId VARCHAR); CREATE TABLE countries (CountryName VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR)

SELECT CountryName FROM countries EXCEPT SELECT T1.CountryName FROM countries AS T1 JOIN CAR_MAKERS AS T2 ON T1.countryId = T2.Country


Question: Which are the car makers which produce at least 2 models and more than 3 car makers ? List the id and the maker .

Context: CREATE TABLE car_makers (id VARCHAR, maker VARCHAR); CREATE TABLE model_list (maker VARCHAR, model VARCHAR); CREATE TABLE car_names (model VARCHAR)

SELECT t1.id, t1.maker FROM car_makers AS t1 JOIN model_list AS t2 ON t1.id = t2.maker GROUP BY t1.id HAVING COUNT(*) >= 2 INTERSECT SELECT t1.id, t1.maker FROM car_makers AS t1 JOIN model_list AS t2 ON t1.id = t2.maker JOIN car_names AS t3 ON t2.model = t3.model GROUP BY t1.id HAVING COUNT(*) > 3


Question: What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?

Context: CREATE TABLE CAR_NAMES (model VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR, model VARCHAR); CREATE TABLE CAR_MAKERS (Id VARCHAR, Maker VARCHAR)

SELECT T1.Id, T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING COUNT(*) >= 2 INTERSECT SELECT T1.Id, T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model GROUP BY T1.Id HAVING COUNT(*) > 3


Question: What are the id and names of the countries which have more than 3 car makers or produce the 'fiat' model?

Context: CREATE TABLE Countries (countryId VARCHAR, CountryName VARCHAR, CountryId VARCHAR); CREATE TABLE CAR_MAKERS (Country VARCHAR, Id VARCHAR); CREATE TABLE MODEL_LIST (Maker VARCHAR, Model VARCHAR)

SELECT T1.countryId, T1.CountryName FROM Countries AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country GROUP BY T1.countryId HAVING COUNT(*) > 3 UNION SELECT T1.countryId, T1.CountryName FROM Countries AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country JOIN MODEL_LIST AS T3 ON T2.Id = T3.Maker WHERE T3.Model = 'fiat'


Question: What are the ids and names of all countries that either have more than 3 car makers or produce fiat model ?

Context: CREATE TABLE model_list (maker VARCHAR, model VARCHAR); CREATE TABLE countries (countryid VARCHAR, countryname VARCHAR); CREATE TABLE car_makers (country VARCHAR, id VARCHAR)

SELECT t1.countryid, t1.countryname FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country GROUP BY t1.countryid HAVING COUNT(*) > 3 UNION SELECT t1.countryid, t1.countryname FROM countries AS t1 JOIN car_makers AS t2 ON t1.countryid = t2.country JOIN model_list AS t3 ON t2.id = t3.maker WHERE t3.model = 'fiat'


Question: Which country does Airline "JetBlue Airways" belong to?

Context: CREATE TABLE AIRLINES (Country VARCHAR, Airline VARCHAR)

SELECT Country FROM AIRLINES WHERE Airline = "JetBlue Airways"


Question: What is the abbreviation of Airline "JetBlue Airways"?

Context: CREATE TABLE AIRLINES (Abbreviation VARCHAR, Airline VARCHAR)

SELECT Abbreviation FROM AIRLINES WHERE Airline = "JetBlue Airways"


Question: List all airline names and their abbreviations in "USA".

Context: CREATE TABLE AIRLINES (Airline VARCHAR, Abbreviation VARCHAR, Country VARCHAR)

SELECT Airline, Abbreviation FROM AIRLINES WHERE Country = "USA"


Question: List the airport code and name in the city of Anthony.

Context: CREATE TABLE AIRPORTS (AirportCode VARCHAR, AirportName VARCHAR, city VARCHAR)

SELECT AirportCode, AirportName FROM AIRPORTS WHERE city = "Anthony"


Question: How many airlines do we have?

Context: CREATE TABLE AIRLINES (Id VARCHAR)


Question: How many airports do we have?

Context: CREATE TABLE AIRPORTS (Id VARCHAR)


Question: How many flights do we have?

Context: CREATE TABLE FLIGHTS (Id VARCHAR)


Question: Which airline has abbreviation 'UAL'?

Context: CREATE TABLE AIRLINES (Airline VARCHAR, Abbreviation VARCHAR)

SELECT Airline FROM AIRLINES WHERE Abbreviation = "UAL"


Question: How many airlines are from USA?

Context: CREATE TABLE AIRLINES (Country VARCHAR)

SELECT COUNT(*) FROM AIRLINES WHERE Country = "USA"


Question: Which city and country is the Alton airport at?

Context: CREATE TABLE AIRPORTS (City VARCHAR, Country VARCHAR, AirportName VARCHAR)

SELECT City, Country FROM AIRPORTS WHERE AirportName = "Alton"


Question: What is the airport name for airport 'AKO'?

Context: CREATE TABLE AIRPORTS (AirportName VARCHAR, AirportCode VARCHAR)

SELECT AirportName FROM AIRPORTS WHERE AirportCode = "AKO"


Question: What are airport names at City 'Aberdeen'?

Context: CREATE TABLE AIRPORTS (AirportName VARCHAR, City VARCHAR)

SELECT AirportName FROM AIRPORTS WHERE City = "Aberdeen"


Question: How many flights depart from 'APG'?

Context: CREATE TABLE FLIGHTS (SourceAirport VARCHAR)

SELECT COUNT(*) FROM FLIGHTS WHERE SourceAirport = "APG"


Question: How many flights have destination ATO?

Context: CREATE TABLE FLIGHTS (DestAirport VARCHAR)

SELECT COUNT(*) FROM FLIGHTS WHERE DestAirport = "ATO"


Question: How many flights depart from City Aberdeen?

Context: CREATE TABLE FLIGHTS (SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)

SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport = T2.AirportCode WHERE T2.City = "Aberdeen"


Question: How many flights arriving in Aberdeen city?

Context: CREATE TABLE FLIGHTS (DestAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)

SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.City = "Aberdeen"


Question: How many flights depart from City 'Aberdeen' and have destination City 'Ashley'?

Context: CREATE TABLE FLIGHTS (DestAirport VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)

SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode JOIN AIRPORTS AS T3 ON T1.SourceAirport = T3.AirportCode WHERE T2.City = "Ashley" AND T3.City = "Aberdeen"


Question: How many flights does airline 'JetBlue Airways' have?

Context: CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR)

SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRLINES AS T2 ON T1.Airline = T2.uid WHERE T2.Airline = "JetBlue Airways"


Question: How many 'United Airlines' flights go to Airport 'ASY'?

Context: CREATE TABLE FLIGHTS (Airline VARCHAR, DestAirport VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR)

SELECT COUNT(*) FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T2.Airline = T1.uid WHERE T1.Airline = "United Airlines" AND T2.DestAirport = "ASY"


Question: How many 'United Airlines' flights depart from Airport 'AHD'?

Context: CREATE TABLE FLIGHTS (Airline VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR)

SELECT COUNT(*) FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T2.Airline = T1.uid WHERE T1.Airline = "United Airlines" AND T2.SourceAirport = "AHD"


Question: How many United Airlines flights go to City 'Aberdeen'?

Context: CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR); CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR); CREATE TABLE FLIGHTS (DestAirport VARCHAR, Airline VARCHAR)

SELECT COUNT(*) FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode JOIN AIRLINES AS T3 ON T3.uid = T1.Airline WHERE T2.City = "Aberdeen" AND T3.Airline = "United Airlines"


Question: Which city has most number of arriving flights?

Context: CREATE TABLE FLIGHTS (DestAirport VARCHAR); CREATE TABLE AIRPORTS (City VARCHAR, AirportCode VARCHAR)

SELECT T1.City FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport GROUP BY T1.City ORDER BY COUNT(*) DESC LIMIT 1


Question: Which city has most number of departing flights?

Context: CREATE TABLE AIRPORTS (City VARCHAR, AirportCode VARCHAR); CREATE TABLE FLIGHTS (SourceAirport VARCHAR)

SELECT T1.City FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.SourceAirport GROUP BY T1.City ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the code of airport that has the highest number of flights?

Context: CREATE TABLE FLIGHTS (DestAirport VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR)

SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport OR T1.AirportCode = T2.SourceAirport GROUP BY T1.AirportCode ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the code of airport that has fewest number of flights?

SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode = T2.DestAirport OR T1.AirportCode = T2.SourceAirport GROUP BY T1.AirportCode ORDER BY COUNT(*) LIMIT 1


Question: Which airline has most number of flights?

Context: CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR)

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the abbreviation and country of the airline that has fewest number of flights?

Context: CREATE TABLE FLIGHTS (Airline VARCHAR); CREATE TABLE AIRLINES (Abbreviation VARCHAR, Country VARCHAR, Airline VARCHAR, uid VARCHAR)

SELECT T1.Abbreviation, T1.Country FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline ORDER BY COUNT(*) LIMIT 1


Question: What are airlines that have some flight departing from airport 'AHD'?

Context: CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR); CREATE TABLE FLIGHTS (Airline VARCHAR, SourceAirport VARCHAR)

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "AHD"


Question: What are airlines that have flights arriving at airport 'AHD'?

Context: CREATE TABLE AIRLINES (Airline VARCHAR, uid VARCHAR); CREATE TABLE FLIGHTS (Airline VARCHAR, DestAirport VARCHAR)

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.DestAirport = "AHD"


Question: Find all airlines that have flights from both airports 'APG' and 'CVO'.

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "APG" INTERSECT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "CVO"


Question: Find all airlines that have flights from airport 'CVO' but not from 'APG'.

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "CVO" EXCEPT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline WHERE T2.SourceAirport = "APG"


Question: Find all airlines that have at least 10 flights.

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING COUNT(*) > 10


Question: Find all airlines that have fewer than 200 flights.

SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid = T2.Airline GROUP BY T1.Airline HAVING COUNT(*) < 200


Question: What are flight numbers of Airline "United Airlines"?

Context: CREATE TABLE AIRLINES (uid VARCHAR, Airline VARCHAR); CREATE TABLE FLIGHTS (FlightNo VARCHAR, Airline VARCHAR)

SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRLINES AS T2 ON T2.uid = T1.Airline WHERE T2.Airline = "United Airlines"


Question: What are flight numbers of flights departing from Airport "APG"?

Context: CREATE TABLE FLIGHTS (FlightNo VARCHAR, SourceAirport VARCHAR)

SELECT FlightNo FROM FLIGHTS WHERE SourceAirport = "APG"


Question: What are flight numbers of flights arriving at Airport "APG"?

Context: CREATE TABLE FLIGHTS (FlightNo VARCHAR, DestAirport VARCHAR)

SELECT FlightNo FROM FLIGHTS WHERE DestAirport = "APG"


Question: What are flight numbers of flights departing from City "Aberdeen "?

Context: CREATE TABLE FLIGHTS (FlightNo VARCHAR, SourceAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)

SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport = T2.AirportCode WHERE T2.City = "Aberdeen"


Question: What are flight numbers of flights arriving at City "Aberdeen"?

Context: CREATE TABLE FLIGHTS (FlightNo VARCHAR, DestAirport VARCHAR); CREATE TABLE AIRPORTS (AirportCode VARCHAR, City VARCHAR)

SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.City = "Aberdeen"


Question: Find the number of flights landing in the city of Aberdeen or Abilene.

Context: CREATE TABLE Airports (AirportCode VARCHAR, city VARCHAR); CREATE TABLE Flights (DestAirport VARCHAR)

SELECT COUNT(*) FROM Flights AS T1 JOIN Airports AS T2 ON T1.DestAirport = T2.AirportCode WHERE T2.city = "Aberdeen" OR T2.city = "Abilene"


Question: Find the name of airports which do not have any flight in and out.

Context: CREATE TABLE Flights (AirportName VARCHAR, AirportCode VARCHAR, SourceAirport VARCHAR, DestAirport VARCHAR); CREATE TABLE Airports (AirportName VARCHAR, AirportCode VARCHAR, SourceAirport VARCHAR, DestAirport VARCHAR)

SELECT AirportName FROM Airports WHERE NOT AirportCode IN (SELECT SourceAirport FROM Flights UNION SELECT DestAirport FROM Flights)


Question: Sort employee names by their age in ascending order.

Context: CREATE TABLE employee (name VARCHAR, age VARCHAR)


Question: What is the number of employees from each city?

Context: CREATE TABLE employee (city VARCHAR)

SELECT COUNT(*), city FROM employee GROUP BY city


Question: Which cities do more than one employee under age 30 come from?

Context: CREATE TABLE employee (city VARCHAR, age INTEGER)

SELECT city FROM employee WHERE age < 30 GROUP BY city HAVING COUNT(*) > 1


Question: Find the number of shops in each location.

Context: CREATE TABLE shop (LOCATION VARCHAR)

SELECT COUNT(*), LOCATION FROM shop GROUP BY LOCATION


Question: Find the manager name and district of the shop whose number of products is the largest.

Context: CREATE TABLE shop (manager_name VARCHAR, district VARCHAR, number_products VARCHAR)

SELECT manager_name, district FROM shop ORDER BY number_products DESC LIMIT 1


Question: find the minimum and maximum number of products of all stores.

Context: CREATE TABLE shop (Number_products INTEGER)

SELECT MIN(Number_products), MAX(Number_products) FROM shop


Question: Return the name, location and district of all shops in descending order of number of products.

Context: CREATE TABLE shop (name VARCHAR, LOCATION VARCHAR, district VARCHAR, number_products VARCHAR)

SELECT name, LOCATION, district FROM shop ORDER BY number_products DESC


Question: Find the names of stores whose number products is more than the average number of products.

Context: CREATE TABLE shop (name VARCHAR, number_products INTEGER)

SELECT name FROM shop WHERE number_products > (SELECT AVG(number_products) FROM shop)


Question: find the name of employee who was awarded the most times in the evaluation.

Context: CREATE TABLE evaluation (Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)

SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID GROUP BY t2.Employee_ID ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the employee who got the highest one time bonus.

Context: CREATE TABLE evaluation (Employee_ID VARCHAR, bonus VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)

SELECT t1.name FROM employee AS t1 JOIN evaluation AS t2 ON t1.Employee_ID = t2.Employee_ID ORDER BY t2.bonus DESC LIMIT 1


Question: Find the names of employees who never won any award in the evaluation.

Context: CREATE TABLE evaluation (name VARCHAR, Employee_ID VARCHAR); CREATE TABLE employee (name VARCHAR, Employee_ID VARCHAR)

SELECT name FROM employee WHERE NOT Employee_ID IN (SELECT Employee_ID FROM evaluation)


Question: What is the name of the shop that is hiring the largest number of employees?

Context: CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (shop_id VARCHAR)

SELECT t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t1.shop_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the shops that do not hire any employee.

Context: CREATE TABLE shop (name VARCHAR, shop_id VARCHAR); CREATE TABLE hiring (name VARCHAR, shop_id VARCHAR)

SELECT name FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM hiring)


Question: Find the number of employees hired in each shop; show the shop name as well.

SELECT COUNT(*), t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t2.name


Question: What is total bonus given in all evaluations?

Context: CREATE TABLE evaluation (bonus INTEGER)


Question: Give me all the information about hiring.

Context: CREATE TABLE hiring (Id VARCHAR)


Question: Which district has both stores with less than 3000 products and stores with more than 10000 products?

Context: CREATE TABLE shop (district VARCHAR, Number_products INTEGER)

SELECT district FROM shop WHERE Number_products < 3000 INTERSECT SELECT district FROM shop WHERE Number_products > 10000


Question: How many different store locations are there?

Context: CREATE TABLE shop (LOCATION VARCHAR)

SELECT COUNT(DISTINCT LOCATION) FROM shop


Question: List document IDs, document names, and document descriptions for all documents.

Context: CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR, document_description VARCHAR)

SELECT document_id, document_name, document_description FROM Documents


Question: What is the document name and template id for document with description with the letter 'w' in it?

Context: CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR, Document_Description VARCHAR)

SELECT document_name, template_id FROM Documents WHERE Document_Description LIKE "%w%"


Question: What is the document id, template id and description for document named "Robbin CV"?

Context: CREATE TABLE Documents (document_id VARCHAR, template_id VARCHAR, Document_Description VARCHAR, document_name VARCHAR)

SELECT document_id, template_id, Document_Description FROM Documents WHERE document_name = "Robbin CV"


Question: How many different templates do all document use?

Context: CREATE TABLE Documents (template_id VARCHAR)

SELECT COUNT(DISTINCT template_id) FROM Documents


Question: How many documents are using the template with type code 'PPT'?

Context: CREATE TABLE Templates (Template_ID VARCHAR, Template_Type_Code VARCHAR); CREATE TABLE Documents (Template_ID VARCHAR)

SELECT COUNT(*) FROM Documents AS T1 JOIN Templates AS T2 ON T1.Template_ID = T2.Template_ID WHERE T2.Template_Type_Code = 'PPT'


Question: Show all template ids and number of documents using each template.

SELECT template_id, COUNT(*) FROM Documents GROUP BY template_id


Question: What is the id and type code for the template used by the most documents?

Context: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (Template_Type_Code VARCHAR, template_id VARCHAR)

SELECT T1.template_id, T2.Template_Type_Code FROM Documents AS T1 JOIN Templates AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show ids for all templates that are used by more than one document.

SELECT template_id FROM Documents GROUP BY template_id HAVING COUNT(*) > 1


Question: Show ids for all templates not used by any document.

Context: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR)

SELECT template_id FROM Templates EXCEPT SELECT template_id FROM Documents


Question: How many templates do we have?

Context: CREATE TABLE Templates (Id VARCHAR)


Question: Show template ids, version numbers, and template type codes for all templates.

Context: CREATE TABLE Templates (template_id VARCHAR, version_number VARCHAR, template_type_code VARCHAR)

SELECT template_id, version_number, template_type_code FROM Templates


Question: Show all distinct template type codes for all templates.

Context: CREATE TABLE Templates (template_type_code VARCHAR)

SELECT DISTINCT template_type_code FROM Templates


Question: What are the ids of templates with template type code PP or PPT?

Context: CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR)

SELECT template_id FROM Templates WHERE template_type_code = "PP" OR template_type_code = "PPT"


Question: How many templates have template type code CV?

SELECT COUNT(*) FROM Templates WHERE template_type_code = "CV"


Question: What is the version number and template type code for the template with version number later than 5?

Context: CREATE TABLE Templates (version_number INTEGER, template_type_code VARCHAR)

SELECT version_number, template_type_code FROM Templates WHERE version_number > 5


Question: Show all template type codes and number of templates for each.

SELECT template_type_code, COUNT(*) FROM Templates GROUP BY template_type_code


Question: Which template type code has most number of templates?

SELECT template_type_code FROM Templates GROUP BY template_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all template type codes with less than three templates.

SELECT template_type_code FROM Templates GROUP BY template_type_code HAVING COUNT(*) < 3


Question: What the smallest version number and its template type code?

Context: CREATE TABLE Templates (template_type_code VARCHAR, Version_Number INTEGER)

SELECT MIN(Version_Number), template_type_code FROM Templates


Question: What is the template type code of the template used by document with the name "Data base"?

Context: CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR); CREATE TABLE Documents (template_id VARCHAR, document_name VARCHAR)

SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T2.document_name = "Data base"


Question: Show all document names using templates with template type code BK.

Context: CREATE TABLE Documents (document_name VARCHAR, template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR)

SELECT T2.document_name FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id WHERE T1.template_type_code = "BK"


Question: Show all template type codes and the number of documents using each type.

Context: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR, template_id VARCHAR)

SELECT T1.template_type_code, COUNT(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code


Question: Which template type code is used by most number of documents?

SELECT T1.template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all template type codes that are not used by any document.

Context: CREATE TABLE Documents (template_id VARCHAR); CREATE TABLE Templates (template_id VARCHAR); CREATE TABLE Templates (template_type_code VARCHAR)

SELECT template_type_code FROM Templates EXCEPT SELECT template_type_code FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id


Question: Show all template type codes and descriptions.

Context: CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)

SELECT template_type_code, template_type_description FROM Ref_template_types


Question: What is the template type descriptions for template type code "AD".

Context: CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR)

SELECT template_type_description FROM Ref_template_types WHERE template_type_code = "AD"


Question: What is the template type code for template type description "Book".

SELECT template_type_code FROM Ref_template_types WHERE template_type_description = "Book"


Question: What are the distinct template type descriptions for the templates ever used by any document?

Context: CREATE TABLE Templates (template_type_code VARCHAR, Template_ID VARCHAR); CREATE TABLE Documents (template_ID VARCHAR); CREATE TABLE Ref_template_types (template_type_description VARCHAR, template_type_code VARCHAR)

SELECT DISTINCT T1.template_type_description FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code JOIN Documents AS T3 ON T2.Template_ID = T3.template_ID


Question: What are the template ids with template type description "Presentation".

Context: CREATE TABLE Templates (template_id VARCHAR, template_type_code VARCHAR); CREATE TABLE Ref_template_types (template_type_code VARCHAR, template_type_description VARCHAR)

SELECT T2.template_id FROM Ref_template_types AS T1 JOIN Templates AS T2 ON T1.template_type_code = T2.template_type_code WHERE T1.template_type_description = "Presentation"


Question: How many paragraphs in total?

Context: CREATE TABLE Paragraphs (Id VARCHAR)


Question: How many paragraphs for the document with name 'Summer Show'?

Context: CREATE TABLE Documents (document_ID VARCHAR, document_name VARCHAR); CREATE TABLE Paragraphs (document_ID VARCHAR)

SELECT COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_ID = T2.document_ID WHERE T2.document_name = 'Summer Show'


Question: Show paragraph details for paragraph with text 'Korea ' .

Context: CREATE TABLE paragraphs (other_details VARCHAR, paragraph_text VARCHAR)

SELECT other_details FROM paragraphs WHERE paragraph_text LIKE 'korea'


Question: Show all paragraph ids and texts for the document with name 'Welcome to NY'.

Context: CREATE TABLE Documents (document_id VARCHAR, Document_Name VARCHAR); CREATE TABLE Paragraphs (paragraph_id VARCHAR, paragraph_text VARCHAR, document_id VARCHAR)

SELECT T1.paragraph_id, T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.Document_Name = 'Welcome to NY'


Question: Show all paragraph texts for the document "Customer reviews".

Context: CREATE TABLE Paragraphs (paragraph_text VARCHAR, document_id VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_name VARCHAR)

SELECT T1.paragraph_text FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id WHERE T2.document_name = "Customer reviews"


Question: Show all document ids and the number of paragraphs in each document. Order by document id.

Context: CREATE TABLE Paragraphs (document_id VARCHAR)

SELECT document_id, COUNT(*) FROM Paragraphs GROUP BY document_id ORDER BY document_id


Question: Show all document ids, names and the number of paragraphs in each document.

Context: CREATE TABLE Documents (document_name VARCHAR, document_id VARCHAR); CREATE TABLE Paragraphs (document_id VARCHAR)

SELECT T1.document_id, T2.document_name, COUNT(*) FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id


Question: List all document ids with at least two paragraphs.

SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) >= 2


Question: What is the document id and name with greatest number of paragraphs?

SELECT T1.document_id, T2.document_name FROM Paragraphs AS T1 JOIN Documents AS T2 ON T1.document_id = T2.document_id GROUP BY T1.document_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the document id with least number of paragraphs?

SELECT document_id FROM Paragraphs GROUP BY document_id ORDER BY COUNT(*) LIMIT 1


Question: What is the document id with 1 to 2 paragraphs?

SELECT document_id FROM Paragraphs GROUP BY document_id HAVING COUNT(*) BETWEEN 1 AND 2


Question: Show the document id with paragraph text 'Brazil' and 'Ireland'.

Context: CREATE TABLE Paragraphs (document_id VARCHAR, paragraph_text VARCHAR)

SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Brazil' INTERSECT SELECT document_id FROM Paragraphs WHERE paragraph_text = 'Ireland'


Question: How many teachers are there?

Context: CREATE TABLE teacher (Id VARCHAR)


Question: List the names of teachers in ascending order of age.

Context: CREATE TABLE teacher (Name VARCHAR, Age VARCHAR)


Question: What are the age and hometown of teachers?

Context: CREATE TABLE teacher (Age VARCHAR, Hometown VARCHAR)


Question: List the name of teachers whose hometown is not `` Little Lever Urban District '' .

Context: CREATE TABLE teacher (name VARCHAR, hometown VARCHAR)

SELECT name FROM teacher WHERE hometown <> "little lever urban district"


Question: Show the name of teachers aged either 32 or 33?

SELECT Name FROM teacher WHERE Age = 32 OR Age = 33


Question: What is the hometown of the youngest teacher?

Context: CREATE TABLE teacher (Hometown VARCHAR, Age VARCHAR)

SELECT Hometown FROM teacher ORDER BY Age LIMIT 1


Question: Show different hometown of teachers and the number of teachers from each hometown.

Context: CREATE TABLE teacher (Hometown VARCHAR)

SELECT Hometown, COUNT(*) FROM teacher GROUP BY Hometown


Question: List the most common hometown of teachers.

Context: CREATE TABLE teacher (Hometown VARCHAR)

SELECT Hometown FROM teacher GROUP BY Hometown ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the hometowns shared by at least two teachers.

Context: CREATE TABLE teacher (Hometown VARCHAR)

SELECT Hometown FROM teacher GROUP BY Hometown HAVING COUNT(*) >= 2


Question: Show names of teachers and the courses they are arranged to teach.

Context: CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course VARCHAR, Course_ID VARCHAR)

SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID


Question: Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.

SELECT T3.Name, T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name


Question: Show the name of the teacher for the math course.

Context: CREATE TABLE course_arrange (Course_ID VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course (Course_ID VARCHAR, Course VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR)

SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math"


Question: Show names of teachers and the number of courses they teach.

Context: CREATE TABLE teacher (Name VARCHAR, Teacher_ID VARCHAR); CREATE TABLE course_arrange (Teacher_ID VARCHAR)

SELECT T2.Name, COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name


Question: Show names of teachers that teach at least two courses.

SELECT T2.Name FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name HAVING COUNT(*) >= 2


Question: List the names of teachers who have not been arranged to teach courses.

Context: CREATE TABLE course_arrange (Name VARCHAR, Teacher_id VARCHAR); CREATE TABLE teacher (Name VARCHAR, Teacher_id VARCHAR)

SELECT Name FROM teacher WHERE NOT Teacher_id IN (SELECT Teacher_id FROM course_arrange)


Question: How many visitors below age 30 are there?

Context: CREATE TABLE visitor (age INTEGER)

SELECT COUNT(*) FROM visitor WHERE age < 30


Question: Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.

Context: CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER)

SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC


Question: What is the average age of the visitors whose membership level is not higher than 4?

Context: CREATE TABLE visitor (age INTEGER, Level_of_membership VARCHAR)

SELECT AVG(age) FROM visitor WHERE Level_of_membership <= 4


Question: Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.

Context: CREATE TABLE visitor (name VARCHAR, Level_of_membership INTEGER, age VARCHAR)

SELECT name, Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC


Question: Find the id and name of the museum that has the most staff members?

Context: CREATE TABLE museum (museum_id VARCHAR, name VARCHAR, num_of_staff VARCHAR)

SELECT museum_id, name FROM museum ORDER BY num_of_staff DESC LIMIT 1


Question: Find the average number of staff working for the museums that were open before 2009.

Context: CREATE TABLE museum (num_of_staff INTEGER, open_year INTEGER)

SELECT AVG(num_of_staff) FROM museum WHERE open_year < 2009


Question: What are the opening year and staff number of the museum named Plaza Museum?

Context: CREATE TABLE museum (Num_of_Staff VARCHAR, Open_Year VARCHAR, name VARCHAR)

SELECT Num_of_Staff, Open_Year FROM museum WHERE name = 'Plaza Museum'


Question: find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.

Context: CREATE TABLE museum (name VARCHAR, num_of_staff INTEGER, open_year INTEGER)

SELECT name FROM museum WHERE num_of_staff > (SELECT MIN(num_of_staff) FROM museum WHERE open_year > 2010)


Question: find the id, name and age for visitors who visited some museums more than once.

Context: CREATE TABLE visit (visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, name VARCHAR, age VARCHAR)

SELECT t1.id, t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t1.id HAVING COUNT(*) > 1


Question: What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?

Context: CREATE TABLE visit (visitor_id VARCHAR, Total_spent INTEGER); CREATE TABLE visitor (name VARCHAR, Level_of_membership VARCHAR, id VARCHAR)

SELECT t2.visitor_id, t1.name, t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t2.visitor_id ORDER BY SUM(t2.Total_spent) DESC LIMIT 1


Question: What are the id and name of the museum visited most times?

Context: CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR); CREATE TABLE visit (Museum_ID VARCHAR)

SELECT t2.Museum_ID, t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the name of the museum that had no visitor yet?

Context: CREATE TABLE visit (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR); CREATE TABLE museum (name VARCHAR, Museum_ID VARCHAR, museum_id VARCHAR)

SELECT name FROM museum WHERE NOT Museum_ID IN (SELECT museum_id FROM visit)


Question: Find the name and age of the visitor who bought the most tickets at once.

Context: CREATE TABLE visitor (name VARCHAR, age VARCHAR, id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, num_of_ticket VARCHAR)

SELECT t1.name, t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1


Question: What are the average and maximum number of tickets bought in all visits?

Context: CREATE TABLE visit (num_of_ticket INTEGER)

SELECT AVG(num_of_ticket), MAX(num_of_ticket) FROM visit


Question: What is the total ticket expense of the visitors whose membership level is 1?

Context: CREATE TABLE visit (Total_spent INTEGER, visitor_id VARCHAR); CREATE TABLE visitor (id VARCHAR, Level_of_membership VARCHAR)

SELECT SUM(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id WHERE t1.Level_of_membership = 1


Question: What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?

Context: CREATE TABLE visitor (name VARCHAR, id VARCHAR); CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR)

SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year < 2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year > 2011


Question: Find the number of visitors who did not visit any museum opened after 2010.

Context: CREATE TABLE museum (Museum_ID VARCHAR, open_year INTEGER); CREATE TABLE visitor (id VARCHAR); CREATE TABLE visit (visitor_id VARCHAR, Museum_ID VARCHAR)

SELECT COUNT(*) FROM visitor WHERE NOT id IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID WHERE t1.open_year > 2010)


Question: How many museums were opened after 2013 or before 2008?

Context: CREATE TABLE museum (open_year VARCHAR)

SELECT COUNT(*) FROM museum WHERE open_year > 2013 OR open_year < 2008


Question: Find the total number of players.

Context: CREATE TABLE players (Id VARCHAR)


Question: Find the total number of matches.

Context: CREATE TABLE matches (Id VARCHAR)


Question: List the first name and birth date of all players from the country with code USA.

Context: CREATE TABLE players (first_name VARCHAR, birth_date VARCHAR, country_code VARCHAR)

SELECT first_name, birth_date FROM players WHERE country_code = 'USA'


Question: Find the average age of losers and winners of all matches.

Context: CREATE TABLE matches (loser_age INTEGER, winner_age INTEGER)

SELECT AVG(loser_age), AVG(winner_age) FROM matches


Question: Find the average rank of winners in all matches.

Context: CREATE TABLE matches (winner_rank INTEGER)


Question: Find the highest rank of losers in all matches.

Context: CREATE TABLE matches (loser_rank INTEGER)


Question: find the number of distinct country codes of all players.

Context: CREATE TABLE players (country_code VARCHAR)

SELECT COUNT(DISTINCT country_code) FROM players


Question: Find the number of distinct name of losers.

Context: CREATE TABLE matches (loser_name VARCHAR)

SELECT COUNT(DISTINCT loser_name) FROM matches


Question: Find the name of tourney that has more than 10 matches.

Context: CREATE TABLE matches (tourney_name VARCHAR)

SELECT tourney_name FROM matches GROUP BY tourney_name HAVING COUNT(*) > 10


Question: List the names of all winners who played in both 2013 and 2016.

Context: CREATE TABLE matches (winner_name VARCHAR, YEAR VARCHAR)

SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016


Question: List the number of all matches who played in years of 2013 or 2016.

Context: CREATE TABLE matches (YEAR VARCHAR)

SELECT COUNT(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016


Question: What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?

Context: CREATE TABLE matches (winner_id VARCHAR, tourney_name VARCHAR); CREATE TABLE players (country_code VARCHAR, first_name VARCHAR, player_id VARCHAR)

SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'WTA Championships' INTERSECT SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'Australian Open'


Question: Find the first name and country code of the oldest player.

Context: CREATE TABLE players (first_name VARCHAR, country_code VARCHAR, birth_date VARCHAR)

SELECT first_name, country_code FROM players ORDER BY birth_date LIMIT 1


Question: List the first and last name of all players in the order of birth date.

Context: CREATE TABLE players (first_name VARCHAR, last_name VARCHAR, birth_date VARCHAR)

SELECT first_name, last_name FROM players ORDER BY birth_date


Question: List the first and last name of all players who are left / L hand in the order of birth date.

Context: CREATE TABLE players (first_name VARCHAR, last_name VARCHAR, hand VARCHAR, birth_date VARCHAR)

SELECT first_name, last_name FROM players WHERE hand = 'L' ORDER BY birth_date


Question: Find the first name and country code of the player who did the most number of tours.

Context: CREATE TABLE players (country_code VARCHAR, first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR, tours VARCHAR)

SELECT T1.country_code, T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC LIMIT 1


Question: Find the year that has the most number of matches.

Context: CREATE TABLE matches (YEAR VARCHAR)

SELECT YEAR FROM matches GROUP BY YEAR ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name and rank points of the winner who won the most times.

Context: CREATE TABLE matches (winner_name VARCHAR, winner_rank_points VARCHAR)

SELECT winner_name, winner_rank_points FROM matches GROUP BY winner_name ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.

Context: CREATE TABLE matches (winner_name VARCHAR, tourney_name VARCHAR, winner_rank_points VARCHAR)

SELECT winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC LIMIT 1


Question: find the names of loser and winner who played in the match with greatest number of minutes.

Context: CREATE TABLE matches (winner_name VARCHAR, loser_name VARCHAR, minutes VARCHAR)

SELECT winner_name, loser_name FROM matches ORDER BY minutes DESC LIMIT 1


Question: Find the average ranking for each player and their first name.

Context: CREATE TABLE players (first_name VARCHAR, player_id VARCHAR); CREATE TABLE rankings (player_id VARCHAR)

SELECT AVG(ranking), T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name


Question: Find the total ranking points for each player and their first name.

SELECT SUM(ranking_points), T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name


Question: find the number of players for each country.

SELECT COUNT(*), country_code FROM players GROUP BY country_code


Question: find the code of the country where has the greatest number of players.

SELECT country_code FROM players GROUP BY country_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the codes of countries that have more than 50 players.

SELECT country_code FROM players GROUP BY country_code HAVING COUNT(*) > 50


Question: Find the total number of tours for each ranking date.

Context: CREATE TABLE rankings (ranking_date VARCHAR, tours INTEGER)

SELECT SUM(tours), ranking_date FROM rankings GROUP BY ranking_date


Question: Find the number of matches happened in each year.

Context: CREATE TABLE matches (YEAR VARCHAR)

SELECT COUNT(*), YEAR FROM matches GROUP BY YEAR


Question: Find the name and rank of the 3 youngest winners across all matches.

Context: CREATE TABLE matches (winner_name VARCHAR, winner_rank VARCHAR, winner_age VARCHAR)

SELECT DISTINCT winner_name, winner_rank FROM matches ORDER BY winner_age LIMIT 3


Question: How many different winners both participated in the WTA Championships and were left handed?

Context: CREATE TABLE matches (winner_name VARCHAR, tourney_name VARCHAR, winner_hand VARCHAR)

SELECT COUNT(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L'


Question: Find the first name, country code and birth date of the winner who has the highest rank points in all matches.

Context: CREATE TABLE players (first_name VARCHAR, country_code VARCHAR, birth_date VARCHAR, player_id VARCHAR); CREATE TABLE matches (winner_id VARCHAR, winner_rank_points VARCHAR)

SELECT T1.first_name, T1.country_code, T1.birth_date FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id ORDER BY T2.winner_rank_points DESC LIMIT 1


Question: Find the number of players for each hand type.

Context: CREATE TABLE players (hand VARCHAR)

SELECT COUNT(*), hand FROM players GROUP BY hand


Question: How many ships ended up being 'Captured'?

Context: CREATE TABLE ship (disposition_of_ship VARCHAR)

SELECT COUNT(*) FROM ship WHERE disposition_of_ship = 'Captured'


Question: List the name and tonnage ordered by in descending alphaetical order for the names.

Context: CREATE TABLE ship (name VARCHAR, tonnage VARCHAR)

SELECT name, tonnage FROM ship ORDER BY name DESC


Question: List the name, date and result of each battle.

Context: CREATE TABLE battle (name VARCHAR, date VARCHAR)


Question: What is maximum and minimum death toll caused each time?

Context: CREATE TABLE death (killed INTEGER)

SELECT MAX(killed), MIN(killed) FROM death


Question: What is the average number of injuries caused each time?

Context: CREATE TABLE death (injured INTEGER)


Question: What are the death and injury situations caused by the ship with tonnage 't'?

Context: CREATE TABLE ship (Id VARCHAR); CREATE TABLE death (killed VARCHAR, injured VARCHAR, caused_by_ship_id VARCHAR)

SELECT T1.killed, T1.injured FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id WHERE T2.tonnage = 't'


Question: What are the name and results of the battles when the bulgarian commander is not 'Boril'

Context: CREATE TABLE battle (name VARCHAR, RESULT VARCHAR, bulgarian_commander VARCHAR)

SELECT name, RESULT FROM battle WHERE bulgarian_commander <> 'Boril'


Question: What are the different ids and names of the battles that lost any 'Brig' type shipes?

Context: CREATE TABLE ship (lost_in_battle VARCHAR, ship_type VARCHAR); CREATE TABLE battle (id VARCHAR, name VARCHAR)

SELECT DISTINCT T1.id, T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.ship_type = 'Brig'


Question: What are the ids and names of the battles that led to more than 10 people killed in total.

Context: CREATE TABLE death (caused_by_ship_id VARCHAR, killed INTEGER); CREATE TABLE battle (id VARCHAR, name VARCHAR); CREATE TABLE ship (lost_in_battle VARCHAR, id VARCHAR)

SELECT T1.id, T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle JOIN death AS T3 ON T2.id = T3.caused_by_ship_id GROUP BY T1.id HAVING SUM(T3.killed) > 10


Question: What is the ship id and name that caused most total injuries?

Context: CREATE TABLE death (caused_by_ship_id VARCHAR); CREATE TABLE ship (Id VARCHAR)

SELECT T2.id, T2.name FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id GROUP BY T2.id ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the distinct battle names which are between bulgarian commander 'Kaloyan' and latin commander 'Baldwin I'?

Context: CREATE TABLE battle (name VARCHAR, bulgarian_commander VARCHAR, latin_commander VARCHAR)

SELECT name FROM battle WHERE bulgarian_commander = 'Kaloyan' AND latin_commander = 'Baldwin I'


Question: How many different results are there for the battles?

Context: CREATE TABLE battle (RESULT VARCHAR)

SELECT COUNT(DISTINCT RESULT) FROM battle


Question: How many battles did not lose any ship with tonnage '225'?

Context: CREATE TABLE ship (id VARCHAR, lost_in_battle VARCHAR, tonnage VARCHAR); CREATE TABLE battle (id VARCHAR, lost_in_battle VARCHAR, tonnage VARCHAR)

SELECT COUNT(*) FROM battle WHERE NOT id IN (SELECT lost_in_battle FROM ship WHERE tonnage = '225')


Question: List the name and date the battle that has lost the ship named 'Lettice' and the ship named 'HMS Atalanta'

Context: CREATE TABLE ship (lost_in_battle VARCHAR, name VARCHAR); CREATE TABLE battle (name VARCHAR, date VARCHAR, id VARCHAR)

SELECT T1.name, T1.date FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.name = 'Lettice' INTERSECT SELECT T1.name, T1.date FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.name = 'HMS Atalanta'


Question: Show names, results and bulgarian commanders of the battles with no ships lost in the 'English Channel'.

Context: CREATE TABLE ship (lost_in_battle VARCHAR, location VARCHAR); CREATE TABLE battle (name VARCHAR, RESULT VARCHAR, bulgarian_commander VARCHAR); CREATE TABLE battle (name VARCHAR, result VARCHAR, bulgarian_commander VARCHAR, id VARCHAR)

SELECT name, RESULT, bulgarian_commander FROM battle EXCEPT SELECT T1.name, T1.result, T1.bulgarian_commander FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.location = 'English Channel'


Question: What are the notes of the death events which has substring 'East'?

Context: CREATE TABLE death (note VARCHAR)

SELECT note FROM death WHERE note LIKE '%East%'


Question: what are all the addresses including line 1 and line 2?

Context: CREATE TABLE addresses (line_1 VARCHAR, line_2 VARCHAR)


Question: How many courses in total are listed?

Context: CREATE TABLE Courses (Id VARCHAR)


Question: How is the math course described?

Context: CREATE TABLE Courses (course_description VARCHAR, course_name VARCHAR)

SELECT course_description FROM Courses WHERE course_name = 'math'


Question: What is the zip code of the address in the city Port Chelsea?

Context: CREATE TABLE Addresses (zip_postcode VARCHAR, city VARCHAR)

SELECT zip_postcode FROM Addresses WHERE city = 'Port Chelsea'


Question: Which department offers the most number of degrees? List department name and id.

Context: CREATE TABLE Degree_Programs (department_id VARCHAR); CREATE TABLE Departments (department_name VARCHAR, department_id VARCHAR)

SELECT T2.department_name, T1.department_id FROM Degree_Programs AS T1 JOIN Departments AS T2 ON T1.department_id = T2.department_id GROUP BY T1.department_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the name and id of the department with the most number of degrees ?

Context: CREATE TABLE degree_programs (department_id VARCHAR); CREATE TABLE departments (department_name VARCHAR, department_id VARCHAR)

SELECT t2.department_name, t1.department_id FROM degree_programs AS t1 JOIN departments AS t2 ON t1.department_id = t2.department_id GROUP BY t1.department_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many departments offer any degree?

Context: CREATE TABLE Degree_Programs (department_id VARCHAR)

SELECT COUNT(DISTINCT department_id) FROM Degree_Programs


Question: How many different degree names are offered?

Context: CREATE TABLE Degree_Programs (degree_summary_name VARCHAR)

SELECT COUNT(DISTINCT degree_summary_name) FROM Degree_Programs


Question: How many degrees does the engineering department offer?

Context: CREATE TABLE Degree_Programs (department_id VARCHAR); CREATE TABLE Departments (department_id VARCHAR, department_name VARCHAR)

SELECT COUNT(*) FROM Departments AS T1 JOIN Degree_Programs AS T2 ON T1.department_id = T2.department_id WHERE T1.department_name = 'engineer'


Question: What are the names and descriptions of all the sections?

Context: CREATE TABLE Sections (section_name VARCHAR, section_description VARCHAR)

SELECT section_name, section_description FROM Sections


Question: What are the names and id of courses having at most 2 sections?

Context: CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Sections (course_id VARCHAR)

SELECT T1.course_name, T1.course_id FROM Courses AS T1 JOIN Sections AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_id HAVING COUNT(*) <= 2


Question: List the section_name in reversed lexicographical order.

Context: CREATE TABLE Sections (section_name VARCHAR)

SELECT section_name FROM Sections ORDER BY section_name DESC


Question: What is the semester which most student registered in? Show both the name and the id.

Context: CREATE TABLE Student_Enrolment (semester_id VARCHAR); CREATE TABLE Semesters (semester_name VARCHAR, semester_id VARCHAR)

SELECT T1.semester_name, T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the description of the department whose name has the substring the computer?

Context: CREATE TABLE Departments (department_description VARCHAR, department_name VARCHAR)

SELECT department_description FROM Departments WHERE department_name LIKE '%computer%'