Question: List the name, IHSAA Football Class, and Mascot of the schools that have more than 6000 of budgeted amount or were founded before 2003, in the order of percent of total invested budget and total budgeted budget.

Context: CREATE TABLE school (School_name VARCHAR, Mascot VARCHAR, IHSAA_Football_Class VARCHAR, school_id VARCHAR); CREATE TABLE budget (school_id VARCHAR, total_budget_percent_invested VARCHAR, total_budget_percent_budgeted VARCHAR)

SELECT T1.School_name, T1.Mascot, T1.IHSAA_Football_Class FROM school AS T1 JOIN budget AS T2 ON T1.school_id = T2.school_id WHERE Budgeted > 6000 OR YEAR < 2003 ORDER BY T2.total_budget_percent_invested, T2.total_budget_percent_budgeted


Question: How many buildings are there?

Context: CREATE TABLE building (Id VARCHAR)


Question: Show the name, street address, and number of floors for all buildings ordered by the number of floors.

Context: CREATE TABLE building (name VARCHAR, street_address VARCHAR, floors VARCHAR)

SELECT name, street_address, floors FROM building ORDER BY floors


Question: What is the name of the tallest building?

Context: CREATE TABLE building (name VARCHAR, height_feet VARCHAR)

SELECT name FROM building ORDER BY height_feet DESC LIMIT 1


Question: What are the average, maximum, and minimum number of floors for all buildings?

Context: CREATE TABLE building (floors INTEGER)

SELECT AVG(floors), MAX(floors), MIN(floors) FROM building


Question: Show the number of buildings with a height above the average or a number of floors above the average.

Context: CREATE TABLE building (height_feet INTEGER, floors INTEGER)

SELECT COUNT(*) FROM building WHERE height_feet > (SELECT AVG(height_feet) FROM building) OR floors > (SELECT AVG(floors) FROM building)


Question: List the names of buildings with at least 200 feet of height and with at least 20 floors.

Context: CREATE TABLE building (name VARCHAR, height_feet VARCHAR, floors VARCHAR)

SELECT name FROM building WHERE height_feet >= 200 AND floors >= 20


Question: Show the names and locations of institutions that are founded after 1990 and have the type "Private".

Context: CREATE TABLE institution (institution VARCHAR, LOCATION VARCHAR, founded VARCHAR, TYPE VARCHAR)

SELECT institution, LOCATION FROM institution WHERE founded > 1990 AND TYPE = 'Private'


Question: Show institution types, along with the number of institutions and total enrollment for each type.

Context: CREATE TABLE institution (TYPE VARCHAR, enrollment INTEGER)

SELECT TYPE, COUNT(*), SUM(enrollment) FROM institution GROUP BY TYPE


Question: Show the institution type with the largest number of institutions.

Context: CREATE TABLE institution (TYPE VARCHAR)

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


Question: Show the institution type with an institution founded after 1990 and an institution with at least 1000 enrollment.

Context: CREATE TABLE institution (TYPE VARCHAR, founded VARCHAR, enrollment VARCHAR)

SELECT TYPE FROM institution WHERE founded > 1990 AND enrollment >= 1000


Question: Show the name of buildings that do not have any institution.

Context: CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (name VARCHAR, building_id VARCHAR)

SELECT name FROM building WHERE NOT building_id IN (SELECT building_id FROM institution)


Question: Show the names of buildings except for those having an institution founded in 2003.

Context: CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE building (name VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded VARCHAR)

SELECT name FROM building EXCEPT SELECT T1.name FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded = 2003


Question: For each building, show the name of the building and the number of institutions in it.

Context: CREATE TABLE building (name VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR)

SELECT T1.name, COUNT(*) FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id GROUP BY T1.building_id


Question: Show the names and heights of buildings with at least two institutions founded after 1880.

Context: CREATE TABLE building (name VARCHAR, height_feet VARCHAR, building_id VARCHAR); CREATE TABLE institution (building_id VARCHAR, founded INTEGER)

SELECT T1.name, T1.height_feet FROM building AS T1 JOIN institution AS T2 ON T1.building_id = T2.building_id WHERE T2.founded > 1880 GROUP BY T1.building_id HAVING COUNT(*) >= 2


Question: Show all the distinct institution types.

Context: CREATE TABLE institution (TYPE VARCHAR)


Question: Show institution names along with the number of proteins for each institution.

Context: CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (institution_id VARCHAR)

SELECT T1.institution, COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id GROUP BY T1.institution_id


Question: How many proteins are associated with an institution founded after 1880 or an institution with type "Private"?

Context: CREATE TABLE institution (institution_id VARCHAR, founded VARCHAR, type VARCHAR); CREATE TABLE protein (institution_id VARCHAR)

SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id WHERE T1.founded > 1880 OR T1.type = 'Private'


Question: Show the protein name and the institution name.

Context: CREATE TABLE institution (institution VARCHAR, institution_id VARCHAR); CREATE TABLE protein (protein_name VARCHAR, institution_id VARCHAR)

SELECT T2.protein_name, T1.institution FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id


Question: How many proteins are associated with an institution in a building with at least 20 floors?

Context: CREATE TABLE institution (institution_id VARCHAR, building_id VARCHAR); CREATE TABLE building (building_id VARCHAR, floors VARCHAR); CREATE TABLE protein (institution_id VARCHAR)

SELECT COUNT(*) FROM institution AS T1 JOIN protein AS T2 ON T1.institution_id = T2.institution_id JOIN building AS T3 ON T3.building_id = T1.building_id WHERE T3.floors >= 20


Question: How many institutions do not have an associated protein in our record?

Context: CREATE TABLE protein (institution_id VARCHAR); CREATE TABLE institution (institution_id VARCHAR)

SELECT COUNT(*) FROM institution WHERE NOT institution_id IN (SELECT institution_id FROM protein)


Question: Show all the locations where no cinema has capacity over 800.

Context: CREATE TABLE cinema (LOCATION VARCHAR, capacity INTEGER)

SELECT LOCATION FROM cinema EXCEPT SELECT LOCATION FROM cinema WHERE capacity > 800


Question: Show all the locations where some cinemas were opened in both year 2010 and year 2011.

Context: CREATE TABLE cinema (LOCATION VARCHAR, openning_year VARCHAR)

SELECT LOCATION FROM cinema WHERE openning_year = 2010 INTERSECT SELECT LOCATION FROM cinema WHERE openning_year = 2011


Question: How many cinema do we have?

Context: CREATE TABLE cinema (Id VARCHAR)


Question: Show name, opening year, and capacity for each cinema.

Context: CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR, capacity VARCHAR)

SELECT name, openning_year, capacity FROM cinema


Question: Show the cinema name and location for cinemas with capacity above average.

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

SELECT name, LOCATION FROM cinema WHERE capacity > (SELECT AVG(capacity) FROM cinema)


Question: What are all the locations with a cinema?

Context: CREATE TABLE cinema (LOCATION VARCHAR)


Question: Show all the cinema names and opening years in descending order of opening year.

Context: CREATE TABLE cinema (name VARCHAR, openning_year VARCHAR)

SELECT name, openning_year FROM cinema ORDER BY openning_year DESC


Question: What are the name and location of the cinema with the largest capacity?

Context: CREATE TABLE cinema (name VARCHAR, LOCATION VARCHAR, capacity VARCHAR)

SELECT name, LOCATION FROM cinema ORDER BY capacity DESC LIMIT 1


Question: Show the average, minimum, and maximum capacity for all the cinemas opened in year 2011 or later.

Context: CREATE TABLE cinema (capacity INTEGER, openning_year VARCHAR)

SELECT AVG(capacity), MIN(capacity), MAX(capacity) FROM cinema WHERE openning_year >= 2011


Question: Show each location and the number of cinemas there.

Context: CREATE TABLE cinema (LOCATION VARCHAR)

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


Question: What is the location with the most cinemas opened in year 2010 or later?

SELECT LOCATION FROM cinema WHERE openning_year >= 2010 GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all the locations with at least two cinemas with capacity above 300.

SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) >= 2


Question: Show the title and director for all films.

Context: CREATE TABLE film (title VARCHAR, directed_by VARCHAR)


Question: Show all directors.

Context: CREATE TABLE film (directed_by VARCHAR)


Question: List all directors along with the number of films directed by each director.

Context: CREATE TABLE film (directed_by VARCHAR)

SELECT directed_by, COUNT(*) FROM film GROUP BY directed_by


Question: What is total number of show times per dat for each cinema?

Context: CREATE TABLE schedule (show_times_per_day INTEGER, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR)

SELECT T2.name, SUM(T1.show_times_per_day) FROM schedule AS T1 JOIN cinema AS T2 ON T1.cinema_id = T2.cinema_id GROUP BY T1.cinema_id


Question: What are the title and maximum price of each film?

Context: CREATE TABLE film (title VARCHAR, film_id VARCHAR); CREATE TABLE schedule (price INTEGER, film_id VARCHAR)

SELECT T2.title, MAX(T1.price) FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id


Question: Show cinema name, film title, date, and price for each record in schedule.

Context: CREATE TABLE schedule (date VARCHAR, price VARCHAR, film_id VARCHAR, cinema_id VARCHAR); CREATE TABLE cinema (name VARCHAR, cinema_id VARCHAR); CREATE TABLE film (title VARCHAR, film_id VARCHAR)

SELECT T3.name, T2.title, T1.date, T1.price FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id JOIN cinema AS T3 ON T1.cinema_id = T3.cinema_id


Question: What are the title and director of the films without any schedule?

Context: CREATE TABLE schedule (title VARCHAR, directed_by VARCHAR, film_id VARCHAR); CREATE TABLE film (title VARCHAR, directed_by VARCHAR, film_id VARCHAR)

SELECT title, directed_by FROM film WHERE NOT film_id IN (SELECT film_id FROM schedule)


Question: Show director with the largest number of show times in total.

Context: CREATE TABLE schedule (film_id VARCHAR, show_times_per_day INTEGER); CREATE TABLE film (directed_by VARCHAR, film_id VARCHAR)

SELECT T2.directed_by FROM schedule AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.directed_by ORDER BY SUM(T1.show_times_per_day) DESC LIMIT 1


Question: Find the locations that have more than one movie theater with capacity above 300.

SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING COUNT(*) > 1


Question: How many films have the word 'Dummy' in their titles?

Context: CREATE TABLE film (title VARCHAR)

SELECT COUNT(*) FROM film WHERE title LIKE "%Dummy%"


Question: Are the customers holding coupons with amount 500 bad or good?

Context: CREATE TABLE discount_coupons (coupon_id VARCHAR, coupon_amount VARCHAR); CREATE TABLE customers (good_or_bad_customer VARCHAR, coupon_id VARCHAR)

SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500


Question: How many bookings did each customer make? List the customer id, first name, and the count.

Context: CREATE TABLE bookings (customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, first_name VARCHAR)

SELECT T1.customer_id, T1.first_name, COUNT(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id


Question: What is the maximum total amount paid by a customer? List the customer id and amount.

Context: CREATE TABLE Payments (customer_id VARCHAR, amount_paid INTEGER)

SELECT customer_id, SUM(amount_paid) FROM Payments GROUP BY customer_id ORDER BY SUM(amount_paid) DESC LIMIT 1


Question: What are the id and the amount of refund of the booking that incurred the most times of payments?

Context: CREATE TABLE Payments (booking_id VARCHAR); CREATE TABLE Bookings (booking_id VARCHAR, amount_of_refund VARCHAR)

SELECT T1.booking_id, T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the id of the product that is booked for 3 times?

Context: CREATE TABLE products_booked (product_id VARCHAR)

SELECT product_id FROM products_booked GROUP BY product_id HAVING COUNT(*) = 3


Question: What is the product description of the product booked with an amount of 102.76?

Context: CREATE TABLE products_for_hire (product_description VARCHAR, product_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booked_amount VARCHAR)

SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76


Question: What are the start date and end date of the booking that has booked the product named 'Book collection A'?

Context: CREATE TABLE bookings (booking_start_date VARCHAR, booking_end_date VARCHAR, booking_id VARCHAR); CREATE TABLE products_booked (product_id VARCHAR, booking_id VARCHAR); CREATE TABLE Products_for_hire (product_id VARCHAR, product_name VARCHAR)

SELECT T3.booking_start_date, T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A'


Question: What are the names of products whose availability equals to 1?

Context: CREATE TABLE view_product_availability (product_id VARCHAR, available_yn VARCHAR); CREATE TABLE products_for_hire (product_name VARCHAR, product_id VARCHAR)

SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1


Question: How many different product types are there?

Context: CREATE TABLE products_for_hire (product_type_code VARCHAR)

SELECT COUNT(DISTINCT product_type_code) FROM products_for_hire


Question: What are the first name, last name, and gender of all the good customers? Order by their last name.

Context: CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, gender_mf VARCHAR, good_or_bad_customer VARCHAR)

SELECT first_name, last_name, gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name


Question: What is the average amount due for all the payments?

Context: CREATE TABLE payments (amount_due INTEGER)


Question: What are the maximum, minimum, and average booked count for the products booked?

Context: CREATE TABLE products_booked (booked_count INTEGER)

SELECT MAX(booked_count), MIN(booked_count), AVG(booked_count) FROM products_booked


Question: What are all the distinct payment types?

Context: CREATE TABLE payments (payment_type_code VARCHAR)

SELECT DISTINCT payment_type_code FROM payments


Question: What are the daily hire costs for the products with substring 'Book' in its name?

Context: CREATE TABLE Products_for_hire (daily_hire_cost VARCHAR, product_name VARCHAR)

SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%'


Question: How many products are never booked with amount higher than 200?

Context: CREATE TABLE products_booked (product_id VARCHAR, booked_amount INTEGER); CREATE TABLE Products_for_hire (product_id VARCHAR, booked_amount INTEGER)

SELECT COUNT(*) FROM Products_for_hire WHERE NOT product_id IN (SELECT product_id FROM products_booked WHERE booked_amount > 200)


Question: What are the coupon amount of the coupons owned by both good and bad customers?

Context: CREATE TABLE Discount_Coupons (coupon_amount VARCHAR, coupon_id VARCHAR); CREATE TABLE customers (coupon_id VARCHAR, good_or_bad_customer VARCHAR)

SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.good_or_bad_customer = 'bad'


Question: What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'

Context: CREATE TABLE payments (payment_date VARCHAR, amount_paid VARCHAR, payment_type_code VARCHAR)

SELECT payment_date FROM payments WHERE amount_paid > 300 OR payment_type_code = 'Check'


Question: What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?

Context: CREATE TABLE products_for_hire (product_name VARCHAR, product_description VARCHAR, product_type_code VARCHAR, daily_hire_cost VARCHAR)

SELECT product_name, product_description FROM products_for_hire WHERE product_type_code = 'Cutlery' AND daily_hire_cost < 20


Question: How many phones are there?

Context: CREATE TABLE phone (Id VARCHAR)


Question: List the names of phones in ascending order of price.

Context: CREATE TABLE phone (Name VARCHAR, Price VARCHAR)


Question: What are the memories and carriers of phones?

Context: CREATE TABLE phone (Memory_in_G VARCHAR, Carrier VARCHAR)


Question: List the distinct carriers of phones with memories bigger than 32.

Context: CREATE TABLE phone (Carrier VARCHAR, Memory_in_G INTEGER)

SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G > 32


Question: Show the names of phones with carrier either "Sprint" or "TMobile".

Context: CREATE TABLE phone (Name VARCHAR, Carrier VARCHAR)

SELECT Name FROM phone WHERE Carrier = "Sprint" OR Carrier = "TMobile"


Question: What is the carrier of the most expensive phone?

Context: CREATE TABLE phone (Carrier VARCHAR, Price VARCHAR)

SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1


Question: Show different carriers of phones together with the number of phones with each carrier.

Context: CREATE TABLE phone (Carrier VARCHAR)

SELECT Carrier, COUNT(*) FROM phone GROUP BY Carrier


Question: Show the most frequently used carrier of the phones.

Context: CREATE TABLE phone (Carrier VARCHAR)

SELECT Carrier FROM phone GROUP BY Carrier ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the carriers that have both phones with memory smaller than 32 and phones with memory bigger than 64.

SELECT Carrier FROM phone WHERE Memory_in_G < 32 INTERSECT SELECT Carrier FROM phone WHERE Memory_in_G > 64


Question: Show the names of phones and the districts of markets they are on.

Context: CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE market (District VARCHAR, Market_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)

SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID


Question: Show the names of phones and the districts of markets they are on, in ascending order of the ranking of the market.

Context: CREATE TABLE market (District VARCHAR, Market_ID VARCHAR, Ranking VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)

SELECT T3.Name, T2.District FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID ORDER BY T2.Ranking


Question: Show the names of phones that are on market with number of shops greater than 50.

Context: CREATE TABLE market (Market_ID VARCHAR, Num_of_shops INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Market_ID VARCHAR, Phone_ID VARCHAR)

SELECT T3.Name FROM phone_market AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID JOIN phone AS T3 ON T1.Phone_ID = T3.Phone_ID WHERE T2.Num_of_shops > 50


Question: For each phone, show its names and total number of stocks.

Context: CREATE TABLE phone_market (Num_of_stock INTEGER, Phone_ID VARCHAR); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)

SELECT T2.Name, SUM(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name


Question: Show the names of phones that have total number of stocks bigger than 2000, in descending order of the total number of stocks.

Context: CREATE TABLE phone_market (Phone_ID VARCHAR, Num_of_stock INTEGER); CREATE TABLE phone (Name VARCHAR, Phone_ID VARCHAR)

SELECT T2.Name FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name HAVING SUM(T1.Num_of_stock) >= 2000 ORDER BY SUM(T1.Num_of_stock) DESC


Question: List the names of phones that are not on any market.

Context: CREATE TABLE phone (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR); CREATE TABLE phone_market (Name VARCHAR, Phone_id VARCHAR, Phone_ID VARCHAR)

SELECT Name FROM phone WHERE NOT Phone_id IN (SELECT Phone_ID FROM phone_market)


Question: How many gas companies are there?

Context: CREATE TABLE company (Id VARCHAR)


Question: List the company name and rank for all companies in the decreasing order of their sales.

Context: CREATE TABLE company (company VARCHAR, rank VARCHAR, Sales_billion VARCHAR)

SELECT company, rank FROM company ORDER BY Sales_billion DESC


Question: Show the company name and the main industry for all companies whose headquarters are not from USA.

Context: CREATE TABLE company (company VARCHAR, main_industry VARCHAR, headquarters VARCHAR)

SELECT company, main_industry FROM company WHERE headquarters <> 'USA'


Question: Show all company names and headquarters in the descending order of market value.

Context: CREATE TABLE company (company VARCHAR, headquarters VARCHAR, market_value VARCHAR)

SELECT company, headquarters FROM company ORDER BY market_value DESC


Question: Show minimum, maximum, and average market value for all companies.

Context: CREATE TABLE company (market_value INTEGER)

SELECT MIN(market_value), MAX(market_value), AVG(market_value) FROM company


Question: Show all main industry for all companies.

Context: CREATE TABLE company (main_industry VARCHAR)

SELECT DISTINCT main_industry FROM company


Question: List all headquarters and the number of companies in each headquarter.

Context: CREATE TABLE company (headquarters VARCHAR)

SELECT headquarters, COUNT(*) FROM company GROUP BY headquarters


Question: Show all main industry and total market value in each industry.

Context: CREATE TABLE company (main_industry VARCHAR, market_value INTEGER)

SELECT main_industry, SUM(market_value) FROM company GROUP BY main_industry


Question: List the main industry with highest total market value and its number of companies.

SELECT main_industry, COUNT(*) FROM company GROUP BY main_industry ORDER BY SUM(market_value) DESC LIMIT 1


Question: Show headquarters with at least two companies in the banking industry.

Context: CREATE TABLE company (headquarters VARCHAR, main_industry VARCHAR)

SELECT headquarters FROM company WHERE main_industry = 'Banking' GROUP BY headquarters HAVING COUNT(*) >= 2


Question: Show gas station id, location, and manager_name for all gas stations ordered by open year.

Context: CREATE TABLE gas_station (station_id VARCHAR, LOCATION VARCHAR, manager_name VARCHAR, open_year VARCHAR)

SELECT station_id, LOCATION, manager_name FROM gas_station ORDER BY open_year


Question: How many gas station are opened between 2000 and 2005?

Context: CREATE TABLE gas_station (open_year INTEGER)

SELECT COUNT(*) FROM gas_station WHERE open_year BETWEEN 2000 AND 2005


Question: Show all locations and the number of gas stations in each location ordered by the count.

Context: CREATE TABLE gas_station (LOCATION VARCHAR)

SELECT LOCATION, COUNT(*) FROM gas_station GROUP BY LOCATION ORDER BY COUNT(*)


Question: Show all headquarters with both a company in banking industry and a company in Oil and gas.

SELECT headquarters FROM company WHERE main_industry = 'Banking' INTERSECT SELECT headquarters FROM company WHERE main_industry = 'Oil and gas'


Question: Show all headquarters without a company in banking industry.

SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking'


Question: Show the company name with the number of gas station.

Context: CREATE TABLE station_company (company_id VARCHAR); CREATE TABLE company (company VARCHAR, company_id VARCHAR)

SELECT T2.company, COUNT(*) FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id


Question: Show company name and main industry without a gas station.

Context: CREATE TABLE station_company (company VARCHAR, main_industry VARCHAR, company_id VARCHAR); CREATE TABLE company (company VARCHAR, main_industry VARCHAR, company_id VARCHAR)

SELECT company, main_industry FROM company WHERE NOT company_id IN (SELECT company_id FROM station_company)


Question: Show the manager name for gas stations belonging to the ExxonMobil company.

Context: CREATE TABLE gas_station (manager_name VARCHAR, station_id VARCHAR); CREATE TABLE station_company (company_id VARCHAR, station_id VARCHAR); CREATE TABLE company (company_id VARCHAR, company VARCHAR)

SELECT T3.manager_name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.company = 'ExxonMobil'


Question: Show all locations where a gas station for company with market value greater than 100 is located.

Context: CREATE TABLE gas_station (location VARCHAR, station_id VARCHAR); CREATE TABLE company (company_id VARCHAR, market_value INTEGER); CREATE TABLE station_company (company_id VARCHAR, station_id VARCHAR)

SELECT T3.location FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id WHERE T2.market_value > 100


Question: Show the manager name with most number of gas stations opened after 2000.

Context: CREATE TABLE gas_station (manager_name VARCHAR, open_year INTEGER)

SELECT manager_name FROM gas_station WHERE open_year > 2000 GROUP BY manager_name ORDER BY COUNT(*) DESC LIMIT 1


Question: order all gas station locations by the opening year.

Context: CREATE TABLE gas_station (LOCATION VARCHAR, open_year VARCHAR)

SELECT LOCATION FROM gas_station ORDER BY open_year


Question: find the rank, company names, market values of the companies in the banking industry order by their sales and profits in billion.

Context: CREATE TABLE company (rank VARCHAR, company VARCHAR, market_value VARCHAR, main_industry VARCHAR, sales_billion VARCHAR, profits_billion VARCHAR)

SELECT rank, company, market_value FROM company WHERE main_industry = 'Banking' ORDER BY sales_billion, profits_billion


Question: find the location and Representative name of the gas stations owned by the companies with top 3 Asset amounts.

Context: CREATE TABLE gas_station (location VARCHAR, Representative_Name VARCHAR, station_id VARCHAR); CREATE TABLE station_company (company_id VARCHAR, station_id VARCHAR); CREATE TABLE company (company_id VARCHAR, Assets_billion VARCHAR)

SELECT T3.location, T3.Representative_Name FROM station_company AS T1 JOIN company AS T2 ON T1.company_id = T2.company_id JOIN gas_station AS T3 ON T1.station_id = T3.station_id ORDER BY T2.Assets_billion DESC LIMIT 3


Question: How many regions do we have?

Context: CREATE TABLE region (Id VARCHAR)


Question: Show all distinct region names ordered by their labels.

Context: CREATE TABLE region (region_name VARCHAR, Label VARCHAR)

SELECT DISTINCT region_name FROM region ORDER BY Label


Question: How many parties do we have?

Context: CREATE TABLE party (party_name VARCHAR)

SELECT COUNT(DISTINCT party_name) FROM party


Question: Show the ministers and the time they took and left office, listed by the time they left office.

Context: CREATE TABLE party (minister VARCHAR, took_office VARCHAR, left_office VARCHAR)

SELECT minister, took_office, left_office FROM party ORDER BY left_office


Question: Show the minister who took office after 1961 or before 1959.

Context: CREATE TABLE party (minister VARCHAR, took_office VARCHAR)

SELECT minister FROM party WHERE took_office > 1961 OR took_office < 1959


Question: Show all ministers who do not belong to Progress Party.

Context: CREATE TABLE party (minister VARCHAR, party_name VARCHAR)

SELECT minister FROM party WHERE party_name <> 'Progress Party'


Question: Show all ministers and parties they belong to in descending order of the time they took office.

Context: CREATE TABLE party (minister VARCHAR, party_name VARCHAR, took_office VARCHAR)

SELECT minister, party_name FROM party ORDER BY took_office DESC


Question: Return the minister who left office at the latest time.

Context: CREATE TABLE party (minister VARCHAR, left_office VARCHAR)

SELECT minister FROM party ORDER BY left_office DESC LIMIT 1


Question: List member names and their party names.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE Member (member_name VARCHAR, party_id VARCHAR)

SELECT T1.member_name, T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id


Question: Show all party names and the number of members in each party.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE Member (party_id VARCHAR)

SELECT T2.party_name, COUNT(*) FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id


Question: What is the name of party with most number of members?

SELECT T2.party_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all party names and their region names.

Context: CREATE TABLE region (region_name VARCHAR, region_id VARCHAR); CREATE TABLE party (party_name VARCHAR, region_id VARCHAR)

SELECT T1.party_name, T2.region_name FROM party AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id


Question: Show names of parties that does not have any members.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE Member (party_name VARCHAR, party_id VARCHAR)

SELECT party_name FROM party WHERE NOT party_id IN (SELECT party_id FROM Member)


Question: Show the member names which are in both the party with id 3 and the party with id 1.

Context: CREATE TABLE member (member_name VARCHAR, party_id VARCHAR)

SELECT member_name FROM member WHERE party_id = 3 INTERSECT SELECT member_name FROM member WHERE party_id = 1


Question: Show member names that are not in the Progress Party.

Context: CREATE TABLE party (party_id VARCHAR, Party_name VARCHAR); CREATE TABLE Member (member_name VARCHAR, party_id VARCHAR)

SELECT T1.member_name FROM Member AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id WHERE T2.Party_name <> "Progress Party"


Question: How many party events do we have?

Context: CREATE TABLE party_events (Id VARCHAR)


Question: Show party names and the number of events for each party.

Context: CREATE TABLE party (party_name VARCHAR, party_id VARCHAR); CREATE TABLE party_events (party_id VARCHAR)

SELECT T2.party_name, COUNT(*) FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id


Question: Show all member names who are not in charge of any event.

Context: CREATE TABLE member (member_name VARCHAR); CREATE TABLE party_events (member_in_charge_id VARCHAR); CREATE TABLE member (member_name VARCHAR, member_id VARCHAR)

SELECT member_name FROM member EXCEPT SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id


Question: What are the names of parties with at least 2 events?

SELECT T2.party_name FROM party_events AS T1 JOIN party AS T2 ON T1.party_id = T2.party_id GROUP BY T1.party_id HAVING COUNT(*) >= 2


Question: What is the name of member in charge of greatest number of events?

Context: CREATE TABLE party_events (member_in_charge_id VARCHAR); CREATE TABLE member (member_name VARCHAR, member_id VARCHAR)

SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY COUNT(*) DESC LIMIT 1


Question: find the event names that have more than 2 records.

Context: CREATE TABLE party_events (event_name VARCHAR)

SELECT event_name FROM party_events GROUP BY event_name HAVING COUNT(*) > 2


Question: How many Annual Meeting events happened in the United Kingdom region?

Context: CREATE TABLE party_events (party_id VARCHAR, Event_Name VARCHAR); CREATE TABLE region (region_id VARCHAR, region_name VARCHAR); CREATE TABLE party (region_id VARCHAR, party_id VARCHAR)

SELECT COUNT(*) FROM region AS t1 JOIN party AS t2 ON t1.region_id = t2.region_id JOIN party_events AS t3 ON t2.party_id = t3.party_id WHERE t1.region_name = "United Kingdom" AND t3.Event_Name = "Annaual Meeting"


Question: How many pilots are there?

Context: CREATE TABLE pilot (Id VARCHAR)


Question: List the names of pilots in ascending order of rank.

Context: CREATE TABLE pilot (Pilot_name VARCHAR, Rank VARCHAR)

SELECT Pilot_name FROM pilot ORDER BY Rank


Question: What are the positions and teams of pilots?

Context: CREATE TABLE pilot (POSITION VARCHAR, Team VARCHAR)


Question: List the distinct positions of pilots older than 30.

Context: CREATE TABLE pilot (POSITION VARCHAR, Age INTEGER)

SELECT DISTINCT POSITION FROM pilot WHERE Age > 30


Question: Show the names of pilots from team "Bradley" or "Fordham".

Context: CREATE TABLE pilot (Pilot_name VARCHAR, Team VARCHAR)

SELECT Pilot_name FROM pilot WHERE Team = "Bradley" OR Team = "Fordham"


Question: What is the joined year of the pilot of the highest rank?

Context: CREATE TABLE pilot (Join_Year VARCHAR, Rank VARCHAR)

SELECT Join_Year FROM pilot ORDER BY Rank LIMIT 1


Question: What are the different nationalities of pilots? Show each nationality and the number of pilots of each nationality.

Context: CREATE TABLE pilot (Nationality VARCHAR)

SELECT Nationality, COUNT(*) FROM pilot GROUP BY Nationality


Question: Show the most common nationality of pilots.

SELECT Nationality FROM pilot GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the pilot positions that have both pilots joining after year 2005 and pilots joining before 2000.

Context: CREATE TABLE pilot (POSITION VARCHAR, Join_Year INTEGER)

SELECT POSITION FROM pilot WHERE Join_Year < 2000 INTERSECT SELECT POSITION FROM pilot WHERE Join_Year > 2005


Question: Show the names of pilots and models of aircrafts they have flied with.

Context: CREATE TABLE pilot_record (Aircraft_ID VARCHAR, Pilot_ID VARCHAR); CREATE TABLE pilot (Pilot_name VARCHAR, Pilot_ID VARCHAR); CREATE TABLE aircraft (Model VARCHAR, Aircraft_ID VARCHAR)

SELECT T3.Pilot_name, T2.Model FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID


Question: Show the names of pilots and fleet series of the aircrafts they have flied with in ascending order of the rank of the pilot.

Context: CREATE TABLE pilot (Pilot_name VARCHAR, Pilot_ID VARCHAR, Rank VARCHAR); CREATE TABLE pilot_record (Aircraft_ID VARCHAR, Pilot_ID VARCHAR); CREATE TABLE aircraft (Fleet_Series VARCHAR, Aircraft_ID VARCHAR)

SELECT T3.Pilot_name, T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID ORDER BY T3.Rank


Question: Show the fleet series of the aircrafts flied by pilots younger than 34

Context: CREATE TABLE pilot_record (Aircraft_ID VARCHAR, Pilot_ID VARCHAR); CREATE TABLE pilot (Pilot_ID VARCHAR, Age INTEGER); CREATE TABLE aircraft (Fleet_Series VARCHAR, Aircraft_ID VARCHAR)

SELECT T2.Fleet_Series FROM pilot_record AS T1 JOIN aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN pilot AS T3 ON T1.Pilot_ID = T3.Pilot_ID WHERE T3.Age < 34


Question: Show the names of pilots and the number of records they have.

Context: CREATE TABLE pilot (Pilot_name VARCHAR, pilot_ID VARCHAR); CREATE TABLE pilot_record (pilot_ID VARCHAR)

SELECT T2.Pilot_name, COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name


Question: Show names of pilots that have more than one record.

SELECT T2.Pilot_name, COUNT(*) FROM pilot_record AS T1 JOIN pilot AS T2 ON T1.pilot_ID = T2.pilot_ID GROUP BY T2.Pilot_name HAVING COUNT(*) > 1


Question: List the names of pilots that do not have any record.

Context: CREATE TABLE pilot_record (Pilot_name VARCHAR, Pilot_ID VARCHAR); CREATE TABLE pilot (Pilot_name VARCHAR, Pilot_ID VARCHAR)

SELECT Pilot_name FROM pilot WHERE NOT Pilot_ID IN (SELECT Pilot_ID FROM pilot_record)


Question: What document status codes do we have?

Context: CREATE TABLE Ref_Document_Status (document_status_code VARCHAR)

SELECT document_status_code FROM Ref_Document_Status


Question: What is the description of document status code 'working'?

Context: CREATE TABLE Ref_Document_Status (document_status_description VARCHAR, document_status_code VARCHAR)

SELECT document_status_description FROM Ref_Document_Status WHERE document_status_code = "working"


Question: What document type codes do we have?

Context: CREATE TABLE Ref_Document_Types (document_type_code VARCHAR)

SELECT document_type_code FROM Ref_Document_Types


Question: What is the description of document type 'Paper'?

Context: CREATE TABLE Ref_Document_Types (document_type_description VARCHAR, document_type_code VARCHAR)

SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper"


Question: What are the shipping agent names?

Context: CREATE TABLE Ref_Shipping_Agents (shipping_agent_name VARCHAR)

SELECT shipping_agent_name FROM Ref_Shipping_Agents


Question: What is the shipping agent code of shipping agent UPS?

Context: CREATE TABLE Ref_Shipping_Agents (shipping_agent_code VARCHAR, shipping_agent_name VARCHAR)

SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS"


Question: What are all role codes?

Context: CREATE TABLE ROLES (role_code VARCHAR)


Question: What is the description of role code ED?

Context: CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR)

SELECT role_description FROM ROLES WHERE role_code = "ED"


Question: How many employees do we have?

Context: CREATE TABLE Employees (Id VARCHAR)


Question: What is the role of the employee named Koby?

Context: CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR); CREATE TABLE Employees (role_code VARCHAR, employee_name VARCHAR)

SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby"


Question: List all document ids and receipt dates of documents.

Context: CREATE TABLE Documents (document_id VARCHAR, receipt_date VARCHAR)

SELECT document_id, receipt_date FROM Documents


Question: How many employees does each role have? List role description, id and number of employees.

Context: CREATE TABLE ROLES (role_description VARCHAR, role_code VARCHAR); CREATE TABLE Employees (role_code VARCHAR)

SELECT T1.role_description, T2.role_code, COUNT(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_code


Question: List roles that have more than one employee. List the role description and number of employees.

Context: CREATE TABLE ROLES (Id VARCHAR); CREATE TABLE Employees (Id VARCHAR)

SELECT Roles.role_description, COUNT(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING COUNT(Employees.employee_id) > 1


Question: What is the document status description of the document with id 1?

Context: CREATE TABLE Documents (Id VARCHAR); CREATE TABLE Ref_Document_Status (Id VARCHAR)

SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1


Question: How many documents have the status code done?

Context: CREATE TABLE Documents (document_status_code VARCHAR)

SELECT COUNT(*) FROM Documents WHERE document_status_code = "done"


Question: List the document type code for the document with the id 2.

Context: CREATE TABLE Documents (document_type_code VARCHAR, document_id VARCHAR)

SELECT document_type_code FROM Documents WHERE document_id = 2


Question: List the document ids for any documents with the status code done and the type code paper.

Context: CREATE TABLE Documents (document_id VARCHAR, document_status_code VARCHAR, document_type_code VARCHAR)

SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper"


Question: What is the name of the shipping agent of the document with id 2?

Context: CREATE TABLE Documents (Id VARCHAR); CREATE TABLE Ref_Shipping_Agents (Id VARCHAR)

SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2


Question: How many documents were shipped by USPS?

SELECT COUNT(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS"


Question: Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.

SELECT Ref_Shipping_Agents.shipping_agent_name, COUNT(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY COUNT(Documents.document_id) DESC LIMIT 1


Question: What is the receipt date of the document with id 3?

Context: CREATE TABLE Documents (receipt_date VARCHAR, document_id VARCHAR)

SELECT receipt_date FROM Documents WHERE document_id = 3


Question: What address was the document with id 4 mailed to?

Context: CREATE TABLE Addresses (document_id VARCHAR); CREATE TABLE Documents_Mailed (document_id VARCHAR)

SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4


Question: What is the mail date of the document with id 7?

Context: CREATE TABLE Documents_Mailed (mailing_date VARCHAR, document_id VARCHAR)

SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7


Question: List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.

Context: CREATE TABLE Ref_Shipping_Agents (document_id VARCHAR, document_status_code VARCHAR, document_type_code VARCHAR); CREATE TABLE Documents (document_id VARCHAR, document_status_code VARCHAR, document_type_code VARCHAR)

SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS"


Question: List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.

SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS"


Question: What is draft detail of the document with id 7?

Context: CREATE TABLE Document_Drafts (draft_details VARCHAR, document_id VARCHAR)

SELECT draft_details FROM Document_Drafts WHERE document_id = 7


Question: How many draft copies does the document with id 2 have?

Context: CREATE TABLE Draft_Copies (document_id VARCHAR)

SELECT COUNT(*) FROM Draft_Copies WHERE document_id = 2


Question: Which document has the most draft copies? List its document id and number of draft copies.

Context: CREATE TABLE Draft_Copies (document_id VARCHAR, copy_number VARCHAR)

SELECT document_id, COUNT(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY COUNT(copy_number) DESC LIMIT 1


Question: Which documents have more than 1 draft copies? List document id and number of draft copies.

SELECT document_id, COUNT(*) FROM Draft_Copies GROUP BY document_id HAVING COUNT(*) > 1


Question: List all employees in the circulation history of the document with id 1. List the employee's name.

Context: CREATE TABLE Circulation_History (Id VARCHAR); CREATE TABLE Employees (Id VARCHAR)

SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1


Question: List the employees who have not showed up in any circulation history of documents. List the employee's name.

Context: CREATE TABLE Circulation_History (employee_name VARCHAR); CREATE TABLE Employees (employee_name VARCHAR)

SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id


Question: Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.

SELECT Employees.employee_name, COUNT(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id, Circulation_History.draft_number, Circulation_History.copy_number ORDER BY COUNT(*) DESC LIMIT 1


Question: For each document, list the number of employees who have showed up in the circulation history of that document. List the document ids and number of employees.

Context: CREATE TABLE Circulation_History (document_id VARCHAR, employee_id VARCHAR)

SELECT document_id, COUNT(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id


Question: List all department names ordered by their starting date.

Context: CREATE TABLE department (dname VARCHAR, mgr_start_date VARCHAR)

SELECT dname FROM department ORDER BY mgr_start_date


Question: find all dependent names who have a spouse relation with some employee.

Context: CREATE TABLE dependent (Dependent_name VARCHAR, relationship VARCHAR)

SELECT Dependent_name FROM dependent WHERE relationship = 'Spouse'


Question: how many female dependents are there?

Context: CREATE TABLE dependent (sex VARCHAR)

SELECT COUNT(*) FROM dependent WHERE sex = 'F'


Question: Find the names of departments that are located in Houston.

Context: CREATE TABLE dept_locations (dnumber VARCHAR, dlocation VARCHAR); CREATE TABLE department (dname VARCHAR, dnumber VARCHAR)

SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber = t2.dnumber WHERE t2.dlocation = 'Houston'


Question: Return the first names and last names of employees who earn more than 30000 in salary.

Context: CREATE TABLE employee (fname VARCHAR, lname VARCHAR, salary INTEGER)

SELECT fname, lname FROM employee WHERE salary > 30000


Question: Find the number of employees of each gender whose salary is lower than 50000.

Context: CREATE TABLE employee (sex VARCHAR, salary INTEGER)

SELECT COUNT(*), sex FROM employee WHERE salary < 50000 GROUP BY sex


Question: list the first and last names, and the addresses of all employees in the ascending order of their birth date.

Context: CREATE TABLE employee (fname VARCHAR, lname VARCHAR, address VARCHAR, Bdate VARCHAR)

SELECT fname, lname, address FROM employee ORDER BY Bdate


Question: what are the event details of the services that have the type code 'Marriage'?

Context: CREATE TABLE EVENTS (event_details VARCHAR, Service_ID VARCHAR); CREATE TABLE Services (Service_ID VARCHAR, Service_Type_Code VARCHAR)

SELECT T1.event_details FROM EVENTS AS T1 JOIN Services AS T2 ON T1.Service_ID = T2.Service_ID WHERE T2.Service_Type_Code = 'Marriage'


Question: What are the ids and details of events that have more than one participants?

Context: CREATE TABLE EVENTS (event_id VARCHAR, event_details VARCHAR, Event_ID VARCHAR); CREATE TABLE Participants_in_Events (Event_ID VARCHAR)

SELECT T1.event_id, T1.event_details FROM EVENTS AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID = T2.Event_ID GROUP BY T1.Event_ID HAVING COUNT(*) > 1


Question: How many events have each participants attended? List the participant id, type and the number.

Context: CREATE TABLE Participants (Participant_ID VARCHAR, Participant_Type_Code VARCHAR); CREATE TABLE Participants_in_Events (Participant_ID VARCHAR)

SELECT T1.Participant_ID, T1.Participant_Type_Code, COUNT(*) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID GROUP BY T1.Participant_ID


Question: What are all the the participant ids, type code and details?

Context: CREATE TABLE Participants (Participant_ID VARCHAR, Participant_Type_Code VARCHAR, Participant_Details VARCHAR)

SELECT Participant_ID, Participant_Type_Code, Participant_Details FROM Participants


Question: How many participants belong to the type 'Organizer'?

Context: CREATE TABLE participants (participant_type_code VARCHAR)

SELECT COUNT(*) FROM participants WHERE participant_type_code = 'Organizer'


Question: List the type of the services in alphabetical order.

Context: CREATE TABLE services (service_type_code VARCHAR)

SELECT service_type_code FROM services ORDER BY service_type_code


Question: List the service id and details for the events.

Context: CREATE TABLE EVENTS (service_id VARCHAR, event_details VARCHAR)

SELECT service_id, event_details FROM EVENTS


Question: How many events had participants whose details had the substring 'Dr.'

Context: CREATE TABLE participants (Participant_ID VARCHAR, participant_details VARCHAR); CREATE TABLE Participants_in_Events (Participant_ID VARCHAR)

SELECT COUNT(*) FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE T1.participant_details LIKE '%Dr.%'


Question: What is the most common participant type?

SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Which service id and type has the least number of participants?

Context: CREATE TABLE Participants_in_Events (Participant_ID VARCHAR, Event_ID VARCHAR); CREATE TABLE services (Service_Type_Code VARCHAR, service_id VARCHAR); CREATE TABLE EVENTS (service_id VARCHAR, Event_ID VARCHAR); CREATE TABLE participants (Participant_ID VARCHAR)

SELECT T3.service_id, T4.Service_Type_Code FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID JOIN EVENTS AS T3 ON T2.Event_ID = T3.Event_ID JOIN services AS T4 ON T3.service_id = T4.service_id GROUP BY T3.service_id ORDER BY COUNT(*) LIMIT 1


Question: What is the id of the event with the most participants?

Context: CREATE TABLE Participants_in_Events (Event_ID VARCHAR)

SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY COUNT(*) DESC LIMIT 1


Question: Which events id does not have any participant with detail 'Kenyatta Kuhn'?

Context: CREATE TABLE Participants (Participant_ID VARCHAR); CREATE TABLE EVENTS (event_id VARCHAR, Participant_Details VARCHAR); CREATE TABLE Participants_in_Events (event_id VARCHAR, Participant_ID VARCHAR)

SELECT event_id FROM EVENTS EXCEPT SELECT T1.event_id FROM Participants_in_Events AS T1 JOIN Participants AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE Participant_Details = 'Kenyatta Kuhn'


Question: Which services type had both successful and failure event details?

Context: CREATE TABLE EVENTS (service_id VARCHAR, event_details VARCHAR); CREATE TABLE services (service_type_code VARCHAR, service_id VARCHAR)

SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Success' INTERSECT SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Fail'


Question: How many events did not have any participants?

Context: CREATE TABLE EVENTS (event_id VARCHAR); CREATE TABLE Participants_in_Events (event_id VARCHAR)

SELECT COUNT(*) FROM EVENTS WHERE NOT event_id IN (SELECT event_id FROM Participants_in_Events)


Question: What are all the distinct participant ids who attended any events?

Context: CREATE TABLE participants_in_Events (participant_id VARCHAR)

SELECT COUNT(DISTINCT participant_id) FROM participants_in_Events


Question: What is the name of the race held most recently?

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

SELECT name FROM races ORDER BY date DESC LIMIT 1


Question: What is the name and date of the most recent race?

SELECT name, date FROM races ORDER BY date DESC LIMIT 1


Question: Find the names of all races held in 2017.

Context: CREATE TABLE races (name VARCHAR, YEAR VARCHAR)

SELECT name FROM races WHERE YEAR = 2017


Question: Find the distinct names of all races held between 2014 and 2017?

Context: CREATE TABLE races (name VARCHAR, YEAR INTEGER)

SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017


Question: List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds?

Context: CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR); CREATE TABLE laptimes (driverid VARCHAR, milliseconds INTEGER)

SELECT DISTINCT T1.forename, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000


Question: Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds?

Context: CREATE TABLE laptimes (driverid VARCHAR, milliseconds INTEGER); CREATE TABLE drivers (driverid VARCHAR, nationality VARCHAR)

SELECT DISTINCT T1.driverid, T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000


Question: What are the forename and surname of the driver who has the smallest laptime?

Context: CREATE TABLE laptimes (driverid VARCHAR, milliseconds VARCHAR); CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR)

SELECT T1.forename, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1


Question: What is the id and family name of the driver who has the longest laptime?

Context: CREATE TABLE drivers (driverid VARCHAR, surname VARCHAR); CREATE TABLE laptimes (driverid VARCHAR, milliseconds VARCHAR)

SELECT T1.driverid, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds DESC LIMIT 1


Question: What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice?

Context: CREATE TABLE drivers (driverid VARCHAR, forename VARCHAR, surname VARCHAR); CREATE TABLE laptimes (driverid VARCHAR)

SELECT T1.driverid, T1.forename, T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE POSITION = '1' GROUP BY T1.driverid HAVING COUNT(*) >= 2


Question: How many drivers participated in the race Australian Grand Prix held in 2009?

Context: CREATE TABLE races (raceid VARCHAR, name VARCHAR); CREATE TABLE results (raceid VARCHAR)

SELECT COUNT(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009


Question: How many drivers did not participate in the races held in 2009?

Context: CREATE TABLE races (driverId VARCHAR, raceId VARCHAR, YEAR VARCHAR); CREATE TABLE results (driverId VARCHAR, raceId VARCHAR, YEAR VARCHAR)

SELECT COUNT(DISTINCT driverId) FROM results WHERE NOT raceId IN (SELECT raceId FROM races WHERE YEAR <> 2009)


Question: Give me a list of names and years of races that had any driver whose forename is Lewis?

Context: CREATE TABLE drivers (driverid VARCHAR, forename VARCHAR); CREATE TABLE races (name VARCHAR, year VARCHAR, raceid VARCHAR); CREATE TABLE results (raceid VARCHAR, driverid VARCHAR)

SELECT T2.name, T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis"


Question: Find the forename and surname of drivers whose nationality is German?

Context: CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, nationality VARCHAR)

SELECT forename, surname FROM drivers WHERE nationality = "German"


Question: Find the id and forenames of drivers who participated both the races with name Australian Grand Prix and the races with name Chinese Grand Prix?

Context: CREATE TABLE races (raceid VARCHAR, name VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR); CREATE TABLE drivers (forename VARCHAR, driverid VARCHAR)

SELECT T2.driverid, T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid, T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"


Question: What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix?

Context: CREATE TABLE races (raceid VARCHAR, name VARCHAR); CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR); CREATE TABLE results (raceid VARCHAR, driverid VARCHAR)

SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"


Question: Find all the forenames of distinct drivers who was in position 1 as standing and won?

Context: CREATE TABLE driverstandings (driverid VARCHAR, position VARCHAR, wins VARCHAR); CREATE TABLE drivers (forename VARCHAR, driverid VARCHAR)

SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1


Question: Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?

Context: CREATE TABLE drivers (forename VARCHAR, driverid VARCHAR); CREATE TABLE driverstandings (driverid VARCHAR, points VARCHAR, position VARCHAR, wins VARCHAR)

SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20


Question: What are the numbers of constructors for different nationalities?

Context: CREATE TABLE constructors (nationality VARCHAR)

SELECT COUNT(*), nationality FROM constructors GROUP BY nationality


Question: What are the numbers of races for each constructor id?

Context: CREATE TABLE constructorStandings (constructorid VARCHAR)

SELECT COUNT(*), constructorid FROM constructorStandings GROUP BY constructorid


Question: What are the names of races that were held after 2017 and the circuits were in the country of Spain?

Context: CREATE TABLE races (name VARCHAR, circuitid VARCHAR, year VARCHAR); CREATE TABLE circuits (circuitid VARCHAR, country VARCHAR)

SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017


Question: What are the unique names of races that held after 2000 and the circuits were in Spain?

SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000


Question: Find the distinct driver id and the stop number of all drivers that have a shorter pit stop duration than some drivers in the race with id 841.

Context: CREATE TABLE pitstops (driverid VARCHAR, STOP VARCHAR, duration INTEGER, raceid VARCHAR)

SELECT DISTINCT driverid, STOP FROM pitstops WHERE duration < (SELECT MAX(duration) FROM pitstops WHERE raceid = 841)


Question: Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?

SELECT DISTINCT driverid, STOP FROM pitstops WHERE duration > (SELECT MIN(duration) FROM pitstops WHERE raceid = 841)


Question: List the forenames of all distinct drivers in alphabetical order?

Context: CREATE TABLE drivers (forename VARCHAR)

SELECT DISTINCT forename FROM drivers ORDER BY forename


Question: List the names of all distinct races in reversed  lexicographic order?

Context: CREATE TABLE races (name VARCHAR)

SELECT DISTINCT name FROM races ORDER BY name DESC


Question: What are the names of races held between 2009 and 2011?

Context: CREATE TABLE races (name VARCHAR, YEAR INTEGER)

SELECT name FROM races WHERE YEAR BETWEEN 2009 AND 2011


Question: What are the names of races held after 12:00:00 or before 09:00:00?

Context: CREATE TABLE races (name VARCHAR, TIME VARCHAR)

SELECT name FROM races WHERE TIME > "12:00:00" OR TIME < "09:00:00"


Question: What are the drivers' first, last names and id who had more than 8 pit stops or participated in more than 5 race results?

Context: CREATE TABLE drivers (forename VARCHAR, surname VARCHAR, driverid VARCHAR); CREATE TABLE results (driverid VARCHAR); CREATE TABLE pitstops (driverid VARCHAR)

SELECT T1.forename, T1.surname, T1.driverid FROM drivers AS T1 JOIN pitstops AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 8 UNION SELECT T1.forename, T1.surname, T1.driverid FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 5


Question: What are the drivers' last names and id who had 11 pit stops and participated in more than 5 race results?

Context: CREATE TABLE drivers (surname VARCHAR, driverid VARCHAR); CREATE TABLE results (driverid VARCHAR); CREATE TABLE pitstops (driverid VARCHAR)

SELECT T1.surname, T1.driverid FROM drivers AS T1 JOIN pitstops AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) = 11 INTERSECT SELECT T1.surname, T1.driverid FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 5


Question: What is the id and last name of the driver who participated in the most races after 2010?

Context: CREATE TABLE drivers (driverid VARCHAR, surname VARCHAR); CREATE TABLE races (raceid VARCHAR, year INTEGER); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR)

SELECT T1.driverid, T1.surname FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid WHERE T3.year > 2010 GROUP BY T1.driverid ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the names of circuits that belong to UK or Malaysia?

Context: CREATE TABLE circuits (name VARCHAR, country VARCHAR)

SELECT name FROM circuits WHERE country = "UK" OR country = "Malaysia"


Question: Find the id and location of circuits that belong to France or Belgium?

Context: CREATE TABLE circuits (circuitid VARCHAR, LOCATION VARCHAR, country VARCHAR)

SELECT circuitid, LOCATION FROM circuits WHERE country = "France" OR country = "Belgium"


Question: Find the names of Japanese constructors that have once earned more than 5 points?

Context: CREATE TABLE constructorstandings (constructorid VARCHAR, points VARCHAR); CREATE TABLE constructors (name VARCHAR, constructorid VARCHAR, nationality VARCHAR)

SELECT T1.name FROM constructors AS T1 JOIN constructorstandings AS T2 ON T1.constructorid = T2.constructorid WHERE T1.nationality = "Japanese" AND T2.points > 5


Question: What is the average fastest lap speed in race named 'Monaco Grand Prix' in 2008 ?

Context: CREATE TABLE results (fastestlapspeed INTEGER, raceid VARCHAR); CREATE TABLE races (raceid VARCHAR, year VARCHAR, name VARCHAR)

SELECT AVG(T2.fastestlapspeed) FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year = 2008 AND T1.name = "Monaco Grand Prix"


Question: What is the maximum fastest lap speed in race named 'Monaco Grand Prix' in 2008 ?

SELECT MAX(T2.fastestlapspeed) FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year = 2008 AND T1.name = "Monaco Grand Prix"


Question: What are the maximum fastest lap speed in races held after 2004 grouped by race name and ordered by year?

Context: CREATE TABLE results (fastestlapspeed INTEGER, raceid VARCHAR); CREATE TABLE races (name VARCHAR, year INTEGER, raceid VARCHAR)

SELECT MAX(T2.fastestlapspeed), T1.name, T1.year FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year > 2014 GROUP BY T1.name ORDER BY T1.year


Question: What are the average fastest lap speed in races held after 2004 grouped by race name and ordered by year?

SELECT AVG(T2.fastestlapspeed), T1.name, T1.year FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid WHERE T1.year > 2014 GROUP BY T1.name ORDER BY T1.year


Question: Find the id, forename and number of races of all drivers who have at least participated in two races?

Context: CREATE TABLE drivers (driverid VARCHAR, forename VARCHAR); CREATE TABLE races (raceid VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR)

SELECT T1.driverid, T1.forename, COUNT(*) FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid GROUP BY T1.driverid HAVING COUNT(*) >= 2


Question: Find the driver id and number of races of all drivers who have at most participated in 30 races?

Context: CREATE TABLE races (raceid VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR); CREATE TABLE drivers (driverid VARCHAR)

SELECT T1.driverid, COUNT(*) FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid GROUP BY T1.driverid HAVING COUNT(*) <= 30


Question: Find the id and surname of the driver who participated the most number of races?

Context: CREATE TABLE drivers (driverid VARCHAR, surname VARCHAR); CREATE TABLE races (raceid VARCHAR); CREATE TABLE results (driverid VARCHAR, raceid VARCHAR)

SELECT T1.driverid, T1.surname FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid JOIN races AS T3 ON T2.raceid = T3.raceid GROUP BY T1.driverid ORDER BY COUNT(*) DESC LIMIT 1


Question: How many technicians are there?

Context: CREATE TABLE technician (Id VARCHAR)


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

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

SELECT Name FROM technician ORDER BY Age


Question: What are the team and starting year of technicians?

Context: CREATE TABLE technician (Team VARCHAR, Starting_Year VARCHAR)

SELECT Team, Starting_Year FROM technician


Question: List the name of technicians whose team is not "NYY".

Context: CREATE TABLE technician (Name VARCHAR, Team VARCHAR)

SELECT Name FROM technician WHERE Team <> "NYY"


Question: Show the name of technicians aged either 36 or 37

SELECT Name FROM technician WHERE Age = 36 OR Age = 37


Question: What is the starting year of the oldest technicians?

Context: CREATE TABLE technician (Starting_Year VARCHAR, Age VARCHAR)

SELECT Starting_Year FROM technician ORDER BY Age DESC LIMIT 1


Question: Show different teams of technicians and the number of technicians in each team.

Context: CREATE TABLE technician (Team VARCHAR)

SELECT Team, COUNT(*) FROM technician GROUP BY Team


Question: Please show the team that has the most number of technicians.

Context: CREATE TABLE technician (Team VARCHAR)

SELECT Team FROM technician GROUP BY Team ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the team that have at least two technicians.

Context: CREATE TABLE technician (Team VARCHAR)

SELECT Team FROM technician GROUP BY Team HAVING COUNT(*) >= 2


Question: Show names of technicians and series of machines they are assigned to repair.

Context: CREATE TABLE machine (Machine_series VARCHAR, machine_id VARCHAR); CREATE TABLE repair_assignment (machine_id VARCHAR, technician_ID VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

SELECT T3.Name, T2.Machine_series FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID


Question: Show names of technicians in ascending order of quality rank of the machine they are assigned.

Context: CREATE TABLE repair_assignment (machine_id VARCHAR, technician_ID VARCHAR); CREATE TABLE machine (machine_id VARCHAR, quality_rank VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

SELECT T3.Name FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID ORDER BY T2.quality_rank


Question: Show names of technicians who are assigned to repair machines with value point more than 70.

Context: CREATE TABLE machine (machine_id VARCHAR, value_points INTEGER); CREATE TABLE repair_assignment (machine_id VARCHAR, technician_ID VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

SELECT T3.Name FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID WHERE T2.value_points > 70


Question: Show names of technicians and the number of machines they are assigned to repair.

Context: CREATE TABLE repair_assignment (technician_ID VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

SELECT T2.Name, COUNT(*) FROM repair_assignment AS T1 JOIN technician AS T2 ON T1.technician_ID = T2.technician_ID GROUP BY T2.Name


Question: List the names of technicians who have not been assigned to repair machines.

Context: CREATE TABLE technician (Name VARCHAR, technician_id VARCHAR); CREATE TABLE repair_assignment (Name VARCHAR, technician_id VARCHAR)

SELECT Name FROM technician WHERE NOT technician_id IN (SELECT technician_id FROM repair_assignment)


Question: Show the starting years shared by technicians from team "CLE" and "CWS".

Context: CREATE TABLE technician (Starting_Year VARCHAR, Team VARCHAR)

SELECT Starting_Year FROM technician WHERE Team = "CLE" INTERSECT SELECT Starting_Year FROM technician WHERE Team = "CWS"


Question: How many entrepreneurs are there?

Context: CREATE TABLE entrepreneur (Id VARCHAR)


Question: List the companies of entrepreneurs in descending order of money requested.

Context: CREATE TABLE entrepreneur (Company VARCHAR, Money_Requested VARCHAR)

SELECT Company FROM entrepreneur ORDER BY Money_Requested DESC


Question: List the companies and the investors of entrepreneurs.

Context: CREATE TABLE entrepreneur (Company VARCHAR, Investor VARCHAR)

SELECT Company, Investor FROM entrepreneur


Question: What is the average money requested by all entrepreneurs?

Context: CREATE TABLE entrepreneur (Money_Requested INTEGER)

SELECT AVG(Money_Requested) FROM entrepreneur


Question: What are the names of people in ascending order of weight?

Context: CREATE TABLE People (Name VARCHAR, Weight VARCHAR)


Question: What are the names of entrepreneurs?

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE entrepreneur (People_ID VARCHAR)

SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID


Question: What are the names of entrepreneurs whose investor is not "Rachel Elnaugh"?

Context: CREATE TABLE entrepreneur (People_ID VARCHAR, Investor VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor <> "Rachel Elnaugh"


Question: What is the weight of the shortest person?

Context: CREATE TABLE people (Weight VARCHAR, Height VARCHAR)

SELECT Weight FROM people ORDER BY Height LIMIT 1


Question: What is the name of the entrepreneur with the greatest weight?

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR, Weight VARCHAR); CREATE TABLE entrepreneur (People_ID VARCHAR)

SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Weight DESC LIMIT 1


Question: What is the total money requested by entrepreneurs with height more than 1.85?

Context: CREATE TABLE people (People_ID VARCHAR, Height INTEGER); CREATE TABLE entrepreneur (Money_Requested INTEGER, People_ID VARCHAR)

SELECT SUM(T1.Money_Requested) FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Height > 1.85


Question: What are the dates of birth of entrepreneurs with investor "Simon Woodroffe" or "Peter Jones"?

Context: CREATE TABLE entrepreneur (People_ID VARCHAR, Investor VARCHAR); CREATE TABLE people (Date_of_Birth VARCHAR, People_ID VARCHAR)

SELECT T2.Date_of_Birth FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor = "Simon Woodroffe" OR T1.Investor = "Peter Jones"


Question: What are the weights of entrepreneurs in descending order of money requested?

Context: CREATE TABLE entrepreneur (People_ID VARCHAR, Money_Requested VARCHAR); CREATE TABLE people (Weight VARCHAR, People_ID VARCHAR)

SELECT T2.Weight FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Money_Requested DESC


Question: What are the investors of entrepreneurs and the corresponding number of entrepreneurs invested by each investor?

Context: CREATE TABLE entrepreneur (Investor VARCHAR)

SELECT Investor, COUNT(*) FROM entrepreneur GROUP BY Investor


Question: What is the investor that has invested in the most number of entrepreneurs?

SELECT Investor FROM entrepreneur GROUP BY Investor ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the investors that have invested in at least two entrepreneurs?

SELECT Investor FROM entrepreneur GROUP BY Investor HAVING COUNT(*) >= 2


Question: List the names of entrepreneurs and their companies in descending order of money requested?

Context: CREATE TABLE entrepreneur (Company VARCHAR, People_ID VARCHAR, Money_Requested VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T2.Name, T1.Company FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Money_Requested


Question: List the names of people that are not entrepreneurs.

Context: CREATE TABLE entrepreneur (Name VARCHAR, People_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT Name FROM people WHERE NOT People_ID IN (SELECT People_ID FROM entrepreneur)


Question: Show the investors shared by entrepreneurs that requested more than 140000 and entrepreneurs that requested less than 120000.

Context: CREATE TABLE entrepreneur (Investor VARCHAR, Money_Requested INTEGER)

SELECT Investor FROM entrepreneur WHERE Money_Requested > 140000 INTERSECT SELECT Investor FROM entrepreneur WHERE Money_Requested < 120000


Question: How many distinct companies are there?

Context: CREATE TABLE entrepreneur (Company VARCHAR)

SELECT COUNT(DISTINCT Company) FROM entrepreneur


Question: Show the company of the tallest entrepreneur.

Context: CREATE TABLE entrepreneur (Company VARCHAR, People_ID VARCHAR); CREATE TABLE people (People_ID VARCHAR, Height VARCHAR)

SELECT T1.Company FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Height DESC LIMIT 1


Question: How many perpetrators are there?

Context: CREATE TABLE perpetrator (Id VARCHAR)


Question: List the date of perpetrators in descending order of the number of people killed.

Context: CREATE TABLE perpetrator (Date VARCHAR, Killed VARCHAR)

SELECT Date FROM perpetrator ORDER BY Killed DESC


Question: List the number of people injured by perpetrators in ascending order.

Context: CREATE TABLE perpetrator (Injured VARCHAR)

SELECT Injured FROM perpetrator ORDER BY Injured


Question: What is the average number of people injured by all perpetrators?

Context: CREATE TABLE perpetrator (Injured INTEGER)


Question: What is the location of the perpetrator with the largest kills.

Context: CREATE TABLE perpetrator (LOCATION VARCHAR, Killed VARCHAR)

SELECT LOCATION FROM perpetrator ORDER BY Killed DESC LIMIT 1


Question: What are the names of people in ascending order of height?

Context: CREATE TABLE People (Name VARCHAR, Height VARCHAR)


Question: What are the names of perpetrators?

Context: CREATE TABLE perpetrator (People_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID


Question: What are the names of perpetrators whose country is not "China"?

Context: CREATE TABLE perpetrator (People_ID VARCHAR, Country VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Country <> "China"


Question: What is the name of the perpetrator with the biggest weight.

Context: CREATE TABLE perpetrator (People_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR, Weight VARCHAR)

SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Weight DESC LIMIT 1


Question: What is the total kills of the perpetrators with height more than 1.84.

Context: CREATE TABLE people (People_ID VARCHAR, Height INTEGER); CREATE TABLE perpetrator (Killed INTEGER, People_ID VARCHAR)

SELECT SUM(T2.Killed) FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Height > 1.84


Question: What are the names of perpetrators in country "China" or "Japan"?

SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Country = "China" OR T2.Country = "Japan"


Question: What are the heights of perpetrators in descending order of the number of people they injured?

Context: CREATE TABLE perpetrator (People_ID VARCHAR, Injured VARCHAR); CREATE TABLE people (Height VARCHAR, People_ID VARCHAR)

SELECT T1.Height FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Injured DESC


Question: What are the countries of perpetrators? Show each country and the corresponding number of perpetrators there.

Context: CREATE TABLE perpetrator (Country VARCHAR)

SELECT Country, COUNT(*) FROM perpetrator GROUP BY Country


Question: What is the country that has the most perpetrators?

SELECT Country, COUNT(*) FROM perpetrator GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the countries that have at least two perpetrators?

SELECT Country, COUNT(*) FROM perpetrator GROUP BY Country HAVING COUNT(*) >= 2


Question: List the names of perpetrators in descending order of the year.

Context: CREATE TABLE perpetrator (People_ID VARCHAR, Year VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Year DESC


Question: List the names of people that are not perpetrators.

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE perpetrator (Name VARCHAR, People_ID VARCHAR)

SELECT Name FROM people WHERE NOT People_ID IN (SELECT People_ID FROM perpetrator)


Question: Show the countries that have both perpetrators with injures more than 50 and perpetrators with injures smaller than 20.

Context: CREATE TABLE perpetrator (Country VARCHAR, Injured INTEGER)

SELECT Country FROM perpetrator WHERE Injured > 50 INTERSECT SELECT Country FROM perpetrator WHERE Injured < 20


Question: How many distinct locations of perpetrators are there?

Context: CREATE TABLE perpetrator (LOCATION VARCHAR)

SELECT COUNT(DISTINCT LOCATION) FROM perpetrator


Question: Show the date of the tallest perpetrator.

Context: CREATE TABLE perpetrator (Date VARCHAR, People_ID VARCHAR); CREATE TABLE people (People_ID VARCHAR, Height VARCHAR)

SELECT T2.Date FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Height DESC LIMIT 1


Question: In which year did the most recent crime happen?

Context: CREATE TABLE perpetrator (YEAR INTEGER)


Question: Report the name of all campuses in Los Angeles county.

Context: CREATE TABLE campuses (campus VARCHAR, county VARCHAR)

SELECT campus FROM campuses WHERE county = "Los Angeles"


Question: What are the names of all campuses located at Chico?

Context: CREATE TABLE campuses (campus VARCHAR, LOCATION VARCHAR)

SELECT campus FROM campuses WHERE LOCATION = "Chico"


Question: Find all the campuses opened in 1958.

Context: CREATE TABLE campuses (campus VARCHAR, YEAR VARCHAR)

SELECT campus FROM campuses WHERE YEAR = 1958


Question: Find the name of the campuses opened before 1800.

Context: CREATE TABLE campuses (campus VARCHAR, YEAR INTEGER)

SELECT campus FROM campuses WHERE YEAR < 1800


Question: Which campus was opened between 1935 and 1939?

SELECT campus FROM campuses WHERE YEAR >= 1935 AND YEAR <= 1939


Question: Find the name of the campuses that is in Northridge, Los Angeles or in San Francisco, San Francisco.

Context: CREATE TABLE campuses (campus VARCHAR, LOCATION VARCHAR, county VARCHAR)

SELECT campus FROM campuses WHERE LOCATION = "Northridge" AND county = "Los Angeles" UNION SELECT campus FROM campuses WHERE LOCATION = "San Francisco" AND county = "San Francisco"


Question: What is the campus fee of "San Jose State University" in year 1996?

Context: CREATE TABLE csu_fees (year VARCHAR); CREATE TABLE campuses (id VARCHAR)

SELECT campusfee FROM campuses AS T1 JOIN csu_fees AS T2 ON T1.id = t2.campus WHERE t1.campus = "San Jose State University" AND T2.year = 1996


Question: What is the campus fee of "San Francisco State University" in year 1996?

SELECT campusfee FROM campuses AS T1 JOIN csu_fees AS T2 ON T1.id = t2.campus WHERE t1.campus = "San Francisco State University" AND T2.year = 1996


Question: Find the count of universities whose campus fee is greater than the average campus fee.

Context: CREATE TABLE csu_fees (campusfee INTEGER)

SELECT COUNT(*) FROM csu_fees WHERE campusfee > (SELECT AVG(campusfee) FROM csu_fees)


Question: Which university is in Los Angeles county and opened after 1950?

Context: CREATE TABLE campuses (campus VARCHAR, county VARCHAR, YEAR VARCHAR)

SELECT campus FROM campuses WHERE county = "Los Angeles" AND YEAR > 1950


Question: Which year has the most degrees conferred?

Context: CREATE TABLE degrees (YEAR VARCHAR, degrees INTEGER)

SELECT YEAR FROM degrees GROUP BY YEAR ORDER BY SUM(degrees) DESC LIMIT 1


Question: Which campus has the most degrees conferred in all times?

Context: CREATE TABLE degrees (campus VARCHAR, degrees INTEGER)

SELECT campus FROM degrees GROUP BY campus ORDER BY SUM(degrees) DESC LIMIT 1


Question: Which campus has the most faculties in year 2003?

Context: CREATE TABLE faculty (campus VARCHAR, year VARCHAR, faculty VARCHAR); CREATE TABLE campuses (campus VARCHAR, id VARCHAR)

SELECT T1.campus FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2003 ORDER BY T2.faculty DESC LIMIT 1


Question: Find the average fee on a CSU campus in 1996

Context: CREATE TABLE csu_fees (campusfee INTEGER, YEAR VARCHAR)

SELECT AVG(campusfee) FROM csu_fees WHERE YEAR = 1996


Question: What is the average fee on a CSU campus in 2005?

SELECT AVG(campusfee) FROM csu_fees WHERE YEAR = 2005


Question: report the total number of degrees granted between 1998 and 2002.

Context: CREATE TABLE campuses (campus VARCHAR, id VARCHAR); CREATE TABLE degrees (degrees INTEGER, campus VARCHAR, year VARCHAR)

SELECT T1.campus, SUM(T2.degrees) FROM campuses AS T1 JOIN degrees AS T2 ON T1.id = T2.campus WHERE T2.year >= 1998 AND T2.year <= 2002 GROUP BY T1.campus


Question: For each Orange county campus, report the number of degrees granted after 2000.

Context: CREATE TABLE campuses (campus VARCHAR, id VARCHAR, county VARCHAR); CREATE TABLE degrees (degrees INTEGER, campus VARCHAR, year VARCHAR)

SELECT T1.campus, SUM(T2.degrees) FROM campuses AS T1 JOIN degrees AS T2 ON T1.id = T2.campus WHERE T1.county = "Orange" AND T2.year >= 2000 GROUP BY T1.campus


Question: Find the names of the campus which has more faculties in 2002 than every campus in Orange county.

Context: CREATE TABLE campuses (campus VARCHAR, id VARCHAR, county VARCHAR); CREATE TABLE faculty (campus VARCHAR, year VARCHAR)

SELECT T1.campus FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2002 AND faculty > (SELECT MAX(faculty) FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2002 AND T1.county = "Orange")


Question: What campus had more than 400 total enrollment but more than 200 full time enrollment in year 1956?

Context: CREATE TABLE enrollments (campus VARCHAR, year VARCHAR); CREATE TABLE campuses (id VARCHAR)

SELECT T1.campus FROM campuses AS t1 JOIN enrollments AS t2 ON t1.id = t2.campus WHERE t2.year = 1956 AND totalenrollment_ay > 400 AND FTE_AY > 200


Question: How many campuses are there in Los Angeles county?

Context: CREATE TABLE campuses (county VARCHAR)

SELECT COUNT(*) FROM campuses WHERE county = "Los Angeles"


Question: How many degrees were conferred in "San Jose State University" in 2000?

Context: CREATE TABLE degrees (Id VARCHAR); CREATE TABLE campuses (Id VARCHAR)

SELECT degrees FROM campuses AS T1 JOIN degrees AS T2 ON t1.id = t2.campus WHERE t1.campus = "San Jose State University" AND t2.year = 2000


Question: What are the degrees conferred in "San Francisco State University" in 2001.

SELECT degrees FROM campuses AS T1 JOIN degrees AS T2 ON t1.id = t2.campus WHERE t1.campus = "San Francisco State University" AND t2.year = 2001


Question: How many faculty is there in total in the year of 2002?

Context: CREATE TABLE faculty (faculty INTEGER, YEAR VARCHAR)

SELECT SUM(faculty) FROM faculty WHERE YEAR = 2002


Question: What is the number of faculty lines in campus "Long Beach State University" in 2002?

Context: CREATE TABLE campuses (id VARCHAR, campus VARCHAR); CREATE TABLE faculty (campus VARCHAR, year VARCHAR)

SELECT faculty FROM faculty AS T1 JOIN campuses AS T2 ON T1.campus = T2.id WHERE T1.year = 2002 AND T2.campus = "Long Beach State University"


Question: How many faculty lines are there in "San Francisco State University" in year 2004?

SELECT faculty FROM faculty AS T1 JOIN campuses AS T2 ON T1.campus = T2.id WHERE T1.year = 2004 AND T2.campus = "San Francisco State University"


Question: List the campus that have between 600 and 1000 faculty lines in year 2004.

Context: CREATE TABLE campuses (id VARCHAR); CREATE TABLE faculty (campus VARCHAR, faculty VARCHAR)

SELECT T1.campus FROM campuses AS t1 JOIN faculty AS t2 ON t1.id = t2.campus WHERE t2.faculty >= 600 AND t2.faculty <= 1000 AND T1.year = 2004


Question: How many faculty lines are there in the university that conferred the most number of degrees in year 2002?

Context: CREATE TABLE campuses (id VARCHAR); CREATE TABLE faculty (faculty VARCHAR); CREATE TABLE degrees (Id VARCHAR)

SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2002 ORDER BY t3.degrees DESC LIMIT 1


Question: How many faculty lines are there in the university that conferred the least number of degrees in year 2001?

SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2001 ORDER BY t3.degrees LIMIT 1


Question: How many undergraduates are there in "San Jose State University" in year 2004?

Context: CREATE TABLE discipline_enrollments (undergraduate INTEGER, campus VARCHAR, year VARCHAR); CREATE TABLE campuses (id VARCHAR, campus VARCHAR)

SELECT SUM(t1.undergraduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Jose State University"


Question: What is the number of graduates in "San Francisco State University" in year 2004?

Context: CREATE TABLE discipline_enrollments (graduate INTEGER, campus VARCHAR, year VARCHAR); CREATE TABLE campuses (id VARCHAR, campus VARCHAR)

SELECT SUM(t1.graduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Francisco State University"


Question: What is the campus fee of "San Francisco State University" in year 2000?

Context: CREATE TABLE campuses (id VARCHAR, campus VARCHAR); CREATE TABLE csu_fees (campusfee VARCHAR, campus VARCHAR, year VARCHAR)

SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Francisco State University" AND t1.year = 2000


Question: Find the campus fee of "San Jose State University" in year 2000.

SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Jose State University" AND t1.year = 2000


Question: How many CSU campuses are there?

Context: CREATE TABLE campuses (Id VARCHAR)


Question: How many candidates are there?

Context: CREATE TABLE candidate (Id VARCHAR)


Question: Which poll resource provided the most number of candidate information?

Context: CREATE TABLE candidate (poll_source VARCHAR)

SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY COUNT(*) DESC LIMIT 1


Question: what are the top 3 highest support rates?

Context: CREATE TABLE candidate (support_rate VARCHAR)

SELECT support_rate FROM candidate ORDER BY support_rate DESC LIMIT 3


Question: Find the id of the candidate who got the lowest oppose rate.

Context: CREATE TABLE candidate (Candidate_ID VARCHAR, oppose_rate VARCHAR)

SELECT Candidate_ID FROM candidate ORDER BY oppose_rate LIMIT 1


Question: Please list support, consider, and oppose rates for each candidate in ascending order by unsure rate.

Context: CREATE TABLE candidate (Support_rate VARCHAR, Consider_rate VARCHAR, Oppose_rate VARCHAR, unsure_rate VARCHAR)

SELECT Support_rate, Consider_rate, Oppose_rate FROM candidate ORDER BY unsure_rate


Question: which poll source does the highest oppose rate come from?

Context: CREATE TABLE candidate (poll_source VARCHAR, oppose_rate VARCHAR)

SELECT poll_source FROM candidate ORDER BY oppose_rate DESC LIMIT 1


Question: List all people names in the order of their date of birth from old to young.

Context: CREATE TABLE people (name VARCHAR, date_of_birth VARCHAR)

SELECT name FROM people ORDER BY date_of_birth


Question: Find the average height and weight for all males (sex is M).

Context: CREATE TABLE people (height INTEGER, weight INTEGER, sex VARCHAR)

SELECT AVG(height), AVG(weight) FROM people WHERE sex = 'M'


Question: find the names of people who are taller than 200 or lower than 190.

Context: CREATE TABLE people (name VARCHAR, height VARCHAR)

SELECT name FROM people WHERE height > 200 OR height < 190


Question: Find the average and minimum weight for each gender.

Context: CREATE TABLE people (sex VARCHAR, weight INTEGER)

SELECT AVG(weight), MIN(weight), sex FROM people GROUP BY sex


Question: Find the name and gender of the candidate who got the highest support rate.

Context: CREATE TABLE candidate (people_id VARCHAR, support_rate VARCHAR); CREATE TABLE people (name VARCHAR, sex VARCHAR, people_id VARCHAR)

SELECT t1.name, t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id ORDER BY t2.support_rate DESC LIMIT 1


Question: Find the name of the candidates whose oppose percentage is the lowest for each sex.

Context: CREATE TABLE candidate (people_id VARCHAR); CREATE TABLE people (name VARCHAR, sex VARCHAR, people_id VARCHAR)

SELECT t1.name, t1.sex, MIN(oppose_rate) FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex


Question: which gender got the highest average uncertain ratio.

Context: CREATE TABLE candidate (people_id VARCHAR, unsure_rate INTEGER); CREATE TABLE people (sex VARCHAR, people_id VARCHAR)

SELECT t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex ORDER BY AVG(t2.unsure_rate) DESC LIMIT 1


Question: what are the names of people who did not participate in the candidate election.

Context: CREATE TABLE candidate (name VARCHAR, people_id VARCHAR); CREATE TABLE people (name VARCHAR, people_id VARCHAR)

SELECT name FROM people WHERE NOT people_id IN (SELECT people_id FROM candidate)


Question: Find the names of the candidates whose support percentage is lower than their oppose rate.

Context: CREATE TABLE candidate (people_id VARCHAR, support_rate INTEGER, oppose_rate VARCHAR); CREATE TABLE people (name VARCHAR, people_id VARCHAR)

SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t2.support_rate < t2.oppose_rate


Question: how many people are there whose weight is higher than 85 for each gender?

SELECT COUNT(*), sex FROM people WHERE weight > 85 GROUP BY sex


Question: find the highest support percentage, lowest consider rate and oppose rate of all candidates.

Context: CREATE TABLE candidate (support_rate INTEGER, consider_rate INTEGER, oppose_rate INTEGER)

SELECT MAX(support_rate), MIN(consider_rate), MIN(oppose_rate) FROM candidate


Question: list all female (sex is F) candidate names in the alphabetical order.

Context: CREATE TABLE candidate (people_id VARCHAR); CREATE TABLE people (name VARCHAR, people_id VARCHAR, sex VARCHAR)

SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t1.sex = 'F' ORDER BY t1.name


Question: find the name of people whose height is lower than the average.

Context: CREATE TABLE people (name VARCHAR, height INTEGER)

SELECT name FROM people WHERE height < (SELECT AVG(height) FROM people)


Question: List all info about all people.

Context: CREATE TABLE people (Id VARCHAR)


Question: Find the titles of all movies directed by steven spielberg.

Context: CREATE TABLE Movie (title VARCHAR, director VARCHAR)

SELECT title FROM Movie WHERE director = 'Steven Spielberg'


Question: What is the name of the movie produced after 2000 and directed by James Cameron?

Context: CREATE TABLE Movie (title VARCHAR, director VARCHAR, YEAR VARCHAR)

SELECT title FROM Movie WHERE director = 'James Cameron' AND YEAR > 2000


Question: How many movies were made before 2000?

Context: CREATE TABLE Movie (YEAR INTEGER)

SELECT COUNT(*) FROM Movie WHERE YEAR < 2000


Question: Who is the director of movie Avatar?

Context: CREATE TABLE Movie (director VARCHAR, title VARCHAR)

SELECT director FROM Movie WHERE title = 'Avatar'


Question: How many reviewers listed?

Context: CREATE TABLE Reviewer (Id VARCHAR)


Question: What is the id of the reviewer whose name has substring “Mike”?

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR)

SELECT rID FROM Reviewer WHERE name LIKE "%Mike%"


Question: What is the reviewer id of Daniel Lewis?

SELECT rID FROM Reviewer WHERE name = "Daniel Lewis"


Question: What is the total number of ratings that has more than 3 stars?

Context: CREATE TABLE Rating (stars INTEGER)

SELECT COUNT(*) FROM Rating WHERE stars > 3


Question: What is the lowest and highest rating star?

Context: CREATE TABLE Rating (stars INTEGER)

SELECT MAX(stars), MIN(stars) FROM Rating


Question: Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order of year.

Context: CREATE TABLE Movie (mID VARCHAR, year VARCHAR); CREATE TABLE Rating (mID VARCHAR, stars VARCHAR)

SELECT DISTINCT YEAR FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year


Question: What are the names of directors who directed movies with 5 star rating? Also return the title of these movies.

Context: CREATE TABLE Movie (director VARCHAR, title VARCHAR, mID VARCHAR); CREATE TABLE Rating (mID VARCHAR, stars VARCHAR)

SELECT T1.director, T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5


Question: What is the average rating star for each reviewer?

Context: CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Rating (stars INTEGER, rID VARCHAR)

SELECT T2.name, AVG(T1.stars) FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T2.name


Question: Find the titles of all movies that have no ratings.

Context: CREATE TABLE Rating (title VARCHAR, mID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

SELECT title FROM Movie WHERE NOT mID IN (SELECT mID FROM Rating)


Question: Find the names of all reviewers who have ratings with a NULL value for the date.

Context: CREATE TABLE Rating (rID VARCHAR); CREATE TABLE Reviewer (rID VARCHAR)

SELECT DISTINCT name FROM Reviewer AS T1 JOIN Rating AS T2 ON T1.rID = T2.rID WHERE ratingDate = "null"


Question: What is the average rating stars and title for the oldest movie?

Context: CREATE TABLE Movie (title VARCHAR, mID VARCHAR, year VARCHAR); CREATE TABLE Rating (stars INTEGER, mID VARCHAR); CREATE TABLE Movie (YEAR INTEGER)

SELECT AVG(T1.stars), T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT MIN(YEAR) FROM Movie)


Question: What is the name of the most recent movie?

Context: CREATE TABLE Movie (title VARCHAR, YEAR INTEGER)

SELECT title FROM Movie WHERE YEAR = (SELECT MAX(YEAR) FROM Movie)


Question: What is the maximum stars and year for the most recent movie?

Context: CREATE TABLE Rating (stars INTEGER, mID VARCHAR); CREATE TABLE Movie (YEAR INTEGER); CREATE TABLE Movie (year VARCHAR, mID VARCHAR)

SELECT MAX(T1.stars), T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT MAX(YEAR) FROM Movie)


Question: What is the names of movies whose created year is after all movies directed by Steven Spielberg?

Context: CREATE TABLE Movie (title VARCHAR, YEAR INTEGER, director VARCHAR)

SELECT title FROM Movie WHERE YEAR > (SELECT MAX(YEAR) FROM Movie WHERE director = "Steven Spielberg")


Question: What are the titles and directors of the movies whose star is greater than the average stars of the movies directed by James Cameron?

Context: CREATE TABLE Rating (mID VARCHAR, stars INTEGER); CREATE TABLE Movie (title VARCHAR, director VARCHAR, mID VARCHAR)

SELECT T2.title, T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars > (SELECT AVG(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.director = "James Cameron")


Question: Return reviewer name, movie title, stars, and ratingDate. And sort the data first by reviewer name, then by movie title, and lastly by number of stars.

Context: CREATE TABLE Rating (stars VARCHAR, ratingDate VARCHAR, mID VARCHAR, rID VARCHAR); CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

SELECT T3.name, T2.title, T1.stars, T1.ratingDate FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID ORDER BY T3.name, T2.title, T1.stars