Question:
What are the distinct ids of customers who made an order after any order that was Cancelled?
Additional table information: table: department_store

Answer: SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT MIN(order_date) FROM Customer_Orders WHERE order_status_code = 'Cancelled')


Question:
What is the phone and email for customer with first name Aniyah and last name Feest?
Additional table information: table: customers_card_transactions

Answer: SELECT customer_phone, customer_email FROM Customers WHERE customer_first_name = 'Aniyah' AND customer_last_name = 'Feest'


Question:
How many distinct incident type codes are there?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(DISTINCT incident_type_code) FROM Behavior_Incident


Question:
Find the names of schools that have more than one donator with donation amount above 8.5.
Additional table information: table: school_finance

Answer: SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING COUNT(*) > 1


Question:
Find the last name of the first ever contact person of the organization with the highest UK Vat number.
Additional table information: table: e_government

Answer: SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.uk_vat_number = (SELECT MAX(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to ASC NULLS FIRST LIMIT 1


Question:
Count the number of transactions.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Financial_transactions


Question:
Find the number of products for each manufacturer, showing the name of each company.
Additional table information: table: manufactory_1

Answer: SELECT COUNT(*), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name


Question:
Find the first names and offices of all instructors who have taught some course and the course description and the department name.
Additional table information: table: college_1

Answer: SELECT T2.emp_fname, T4.prof_office, T3.crs_description, T5.dept_name FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN professor AS T4 ON T2.emp_num = T4.emp_num JOIN department AS T5 ON T4.dept_code = T5.dept_code


Question:
Show all flight numbers with aircraft Airbus A340-300.
Additional table information: table: flight_1

Answer: SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = 'Airbus A340-300'


Question:
List the names of all the channels owned by either CCTV or HBS
Additional table information: table: program_share

Answer: SELECT name FROM channel WHERE OWNER = 'CCTV' OR OWNER = 'HBS'


Question:
Which parts have more than 2 faults? Show the part name and id.
Additional table information: table: assets_maintenance

Answer: SELECT T1.part_name, T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_id HAVING COUNT(*) > 2


Question:
What are the different classes of races, and how many races correspond to each?
Additional table information: table: race_track

Answer: SELECT CLASS, COUNT(*) FROM race GROUP BY CLASS


Question:
Find the id of users who are followed by Mary and Susan.
Additional table information: table: twitter_1

Answer: SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = 'Mary' INTERSECT SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = 'Susan'


Question:
Show the product type codes that have at least two products.
Additional table information: table: solvency_ii

Answer: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*) >= 2


Question:
Which clubs have one or more members whose advisor is '1121'?
Additional table information: table: club_1

Answer: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.advisor = 1121


Question:
What are the names of departments that have at least one employee.
Additional table information: table: hr_1

Answer: SELECT DISTINCT T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id


Question:
What are the names of reviewers who had rated 3 star and 4 star?
Additional table information: table: movie_1

Answer: SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 4


Question:
What are the course codes for every class that the student with the last name Smithson took?
Additional table information: table: college_1

Answer: SELECT T1.crs_code FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T3.stu_num = T2.stu_num WHERE T3.stu_lname = 'Smithson'


Question:
Show all the buildings along with the number of faculty members the buildings have.
Additional table information: table: activity_1

Answer: SELECT building, COUNT(*) FROM Faculty GROUP BY building


Question:
What are the different driver ids and nationalities of all drivers who had a laptime of more than 100000 milliseconds?
Additional table information: table: formula_1

Answer: 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 is the name of the game that has been played the most?
Additional table information: table: game_1

Answer: SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid ORDER BY SUM(hours_played) DESC LIMIT 1


Question:
Compute the average salary of the players in the team called 'Boston Red Stockings'.
Additional table information: table: baseball_1

Answer: SELECT AVG(T1.salary) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings'


Question:
What are the cities that have a branch that opened in 2001 and a branch with more than 100 members?
Additional table information: table: shop_membership

Answer: SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100


Question:
How films are produced by each studio?
Additional table information: table: film_rank

Answer: SELECT Studio, COUNT(*) FROM film GROUP BY Studio


Question:
For each zip code, find the ids of all trips that have a higher average mean temperature above 60?
Additional table information: table: bike_1

Answer: SELECT T1.id FROM trip AS T1 JOIN weather AS T2 ON T1.zip_code = T2.zip_code GROUP BY T2.zip_code HAVING AVG(T2.mean_temperature_f) > 60


Question:
How many different instruments are used in the song 'Badlands'?
Additional table information: table: music_2

Answer: SELECT COUNT(DISTINCT instrument) FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = 'Badlands'


Question:
What are the total number of credits offered by each department?
Additional table information: table: college_1

Answer: SELECT SUM(T1.crs_credit), T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code


Question:
What are the types of vocals that the musician with the first name 'Solveig' played in the song 'A Bar in Amsterdam'?
Additional table information: table: music_2

Answer: SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid JOIN band AS T3 ON T1.bandmate = T3.id WHERE T3.firstname = 'Solveig' AND T2.title = 'A Bar In Amsterdam'


Question:
Show card type codes with at least 5 cards.
Additional table information: table: customers_card_transactions

Answer: SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING COUNT(*) >= 5


Question:
In February, which city marks the highest temperature?
Additional table information: table: city_record

Answer: SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id ORDER BY T2.Feb DESC LIMIT 1


Question:
Show names of musicals which have at least three actors.
Additional table information: table: musical

Answer: SELECT T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID HAVING COUNT(*) >= 3


Question:
For directors who had more than one movie, return the titles and produced years of all movies directed by them.
Additional table information: table: movie_1

Answer: SELECT T1.title, T1.year FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title <> T2.title


Question:
Find the average millisecond length of Latin and Pop tracks.
Additional table information: table: chinook_1

Answer: SELECT AVG(Milliseconds) FROM GENRE AS T1 JOIN TRACK AS T2 ON T1.GenreId = T2.GenreId WHERE T1.Name = 'Latin' OR T1.Name = 'Pop'


Question:
Return the phone and email of the customer with the first name Aniyah and last name Feest.
Additional table information: table: customers_card_transactions

Answer: SELECT customer_phone, customer_email FROM Customers WHERE customer_first_name = 'Aniyah' AND customer_last_name = 'Feest'


Question:
What are the teams that have both wrestlers eliminated by Orton and wrestlers eliminated by Benjamin?
Additional table information: table: wrestler

Answer: SELECT Team FROM Elimination WHERE Eliminated_By = 'Orton' INTERSECT SELECT Team FROM Elimination WHERE Eliminated_By = 'Benjamin'


Question:
What is the current series where the new series began in June 2011?
Additional table information: table: regional_marketing
columns: state_territory, text_bg_color, format, current_slogan, current_series, Notes

Answer: SELECT current_series FROM "regional_marketing" WHERE Notes = 'New series began in June 2011'


Question:
What are the names of all races held between 2009 and 2011?
Additional table information: table: formula_1

Answer: SELECT name FROM races WHERE YEAR BETWEEN 2009 AND 2011


Question:
What are the names of companies with revenue less than the lowest revenue of any manufacturer in Austin?
Additional table information: table: manufactory_1

Answer: SELECT name FROM manufacturers WHERE revenue < (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin')


Question:
List the clubs that have at least a member with advisor '1121'.
Additional table information: table: club_1

Answer: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.advisor = 1121


Question:
What are the titles of films that are either longer than 100 minutes or rated PG other than those that cost more than 200 to replace?
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200


Question:
Find all the campuses opened in 1958.
Additional table information: table: csu_1

Answer: SELECT campus FROM campuses WHERE YEAR = 1958


Question:
Return the themes of farm competitions, sorted by year ascending.
Additional table information: table: farm

Answer: SELECT Theme FROM farm_competition ORDER BY YEAR ASC NULLS FIRST


Question:
Find the title of course that is provided by both Statistics and Psychology departments.
Additional table information: table: college_2

Answer: SELECT title FROM course WHERE dept_name = 'Statistics' INTERSECT SELECT title FROM course WHERE dept_name = 'Psychology'


Question:
Find the name of dorms that do not have amenity TV Lounge.
Additional table information: table: dorm_1

Answer: SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge'


Question:
What is the description of the color for most products?
Additional table information: table: products_gen_characteristics

Answer: SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code GROUP BY t2.color_description ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the names of patients who have made appointments.
Additional table information: table: hospital_1

Answer: SELECT name FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn


Question:
Which vocal type did the musician with last name 'Heilo' played in the song with title 'Der Kapitan'?
Additional table information: table: music_2

Answer: SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid JOIN band AS T3 ON T1.bandmate = T3.id WHERE T3.lastname = 'Heilo' AND T2.title = 'Der Kapitan'


Question:
What are the personal names used both by some course authors and some students?
Additional table information: table: e_learning

Answer: SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students


Question:
For each manufacturer name, what are the names and prices of their most expensive product?
Additional table information: table: manufactory_1

Answer: SELECT T1.Name, MAX(T1.Price), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name


Question:
How many events did not have any participants?
Additional table information: table: local_govt_in_alabama

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


Question:
What is the last date that a staff member left a project?
Additional table information: table: tracking_grants_for_research

Answer: SELECT date_to FROM Project_Staff ORDER BY date_to DESC LIMIT 1


Question:
Count the number of courses with more than 2 credits.
Additional table information: table: college_3

Answer: SELECT COUNT(*) FROM COURSE WHERE Credits > 2


Question:
What are total transaction amounts for each transaction type?
Additional table information: table: customers_and_invoices

Answer: SELECT transaction_type, SUM(transaction_amount) FROM Financial_transactions GROUP BY transaction_type


Question:
What are the ids and trade names of the medicine that can interact with at least 3 enzymes?
Additional table information: table: medicine_enzyme_interaction

Answer: SELECT T1.id, T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 3


Question:
Find the accreditation level that more than 3 phones use.
Additional table information: table: phone_1

Answer: SELECT Accreditation_level FROM phone GROUP BY Accreditation_level HAVING COUNT(*) > 3


Question:
Return the names and locations of shops, ordered by name in alphabetical order.
Additional table information: table: device

Answer: SELECT Shop_Name, LOCATION FROM shop ORDER BY Shop_Name ASC NULLS FIRST


Question:
Which problem id and log id are assigned to the staff named Rylan Homenick?
Additional table information: table: tracking_software_problems

Answer: SELECT DISTINCT T2.problem_id, T2.problem_log_id FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T1.staff_first_name = 'Rylan' AND T1.staff_last_name = 'Homenick'


Question:
How many parks are there in Atlanta city?
Additional table information: table: baseball_1

Answer: SELECT COUNT(*) FROM park WHERE city = 'Atlanta'


Question:
What are the ids of all male students who do not play football?
Additional table information: table: game_1

Answer: SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = 'Football'


Question:
What is the name of the aircraft that has won an award the most?
Additional table information: table: aircraft

Answer: SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID = T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the fleet series of the aircrafts flied by pilots younger than 34
Additional table information: table: pilot_record

Answer: 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:
What is the product ID of the most frequently ordered item on invoices?
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT Product_ID FROM INVOICES GROUP BY Product_ID ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the the lesson ids of all staff taught by Janessa Sawayn whose nickname has the letter s?
Additional table information: table: driving_school

Answer: SELECT T1.lesson_id FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Janessa' AND T2.last_name = 'Sawayn' AND nickname LIKE '%s%'


Question:
How many allergy entries are there?
Additional table information: table: allergy_1

Answer: SELECT COUNT(DISTINCT allergy) FROM Allergy_type


Question:
List the branch name and city without any registered members.
Additional table information: table: shop_membership

Answer: SELECT name, city FROM branch WHERE NOT branch_id IN (SELECT branch_id FROM membership_register_branch)


Question:
Show the movie titles and book titles for all companies in China.
Additional table information: table: culture_company

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


Question:
What are the names of the storms that affected both the regions of Afghanistan and Albania?
Additional table information: table: storm_record

Answer: SELECT T3.Name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T2.Region_name = 'Afghanistan' INTERSECT SELECT T3.Name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T2.Region_name = 'Albania'


Question:
Find the last and first name of students who are playing Football or Lacrosse.
Additional table information: table: game_1

Answer: SELECT T2.lname, T2.fname FROM SportsInfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.SportName = 'Football' OR T1.SportName = 'Lacrosse'


Question:
Which clubs have one or more members from the city with code 'HOU'? Give me the names of the clubs.
Additional table information: table: club_1

Answer: SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = 'HOU'


Question:
What is the age of student Linda Smith?
Additional table information: table: restaurant_1

Answer: SELECT Age FROM Student WHERE Fname = 'Linda' AND Lname = 'Smith'


Question:
What are the last names and ages of the students who are allergic to milk and cat?
Additional table information: table: allergy_1

Answer: SELECT lname, age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = 'Milk' INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy = 'Cat')


Question:
What are the names and balances of checking accounts belonging to the customer with the lowest savings balance?
Additional table information: table: small_bank_1

Answer: SELECT T1.name, T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T3.balance NULLS FIRST LIMIT 1


Question:
Find the subject ID, subject name, and the corresponding number of available courses for each subject.
Additional table information: table: e_learning

Answer: SELECT T1.subject_id, T2.subject_name, COUNT(*) FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id GROUP BY T1.subject_id


Question:
How many instructors teach a course in the Spring of 2010?
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT ID) FROM teaches WHERE semester = 'Spring' AND YEAR = 2010


Question:
What is the first name, gpa and phone number of the top 5 students with highest gpa?
Additional table information: table: college_1

Answer: SELECT stu_gpa, stu_phone, stu_fname FROM student ORDER BY stu_gpa DESC LIMIT 5


Question:
Who is the founders of companies whose first letter is S?
Additional table information: table: manufactory_1

Answer: SELECT founder FROM manufacturers WHERE name LIKE 'S%'


Question:
List all information regarding the basketball match.
Additional table information: table: university_basketball

Answer: SELECT * FROM basketball_match


Question:
What is the name of the highest rated wine?
Additional table information: table: wine_1

Answer: SELECT Name FROM WINE ORDER BY Score NULLS FIRST LIMIT 1


Question:
Show all ministers who do not belong to Progress Party.
Additional table information: table: party_people

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


Question:
What are the names of all the playlists?
Additional table information: table: store_1

Answer: SELECT name FROM playlists


Question:
How many clubs does the student named 'Eric Tai' belong to?
Additional table information: table: club_1

Answer: SELECT COUNT(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = 'Eric' AND t3.lname = 'Tai'


Question:
What is the founded year of the non public school that was founded most recently?
Additional table information: table: university_basketball

Answer: SELECT founded FROM university WHERE affiliation <> 'Public' ORDER BY founded DESC LIMIT 1


Question:
Find the name of the customer that has been involved in the most policies.
Additional table information: table: insurance_and_eClaims

Answer: SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the address and staff number of the shops that do not have any happy hour.
Additional table information: table: coffee_shop

Answer: SELECT address, num_of_staff FROM shop WHERE NOT shop_id IN (SELECT shop_id FROM happy_hour)


Question:
How many students are 18 years old?
Additional table information: table: allergy_1

Answer: SELECT COUNT(*) FROM Student WHERE age = 18


Question:
Return the name of the mountain with the greatest height.
Additional table information: table: climbing

Answer: SELECT Name FROM mountain ORDER BY Height DESC LIMIT 1


Question:
What is the last name of the youngest student?
Additional table information: table: allergy_1

Answer: SELECT LName FROM Student WHERE age = (SELECT MIN(age) FROM Student)


Question:
What are the ids of all the employees who have destroyed documents?
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT DISTINCT Destroyed_by_Employee_ID FROM Documents_to_be_destroyed


Question:
How many different majors are there and how many different city codes are there for each student?
Additional table information: table: dorm_1

Answer: SELECT COUNT(DISTINCT major), COUNT(DISTINCT city_code) FROM student


Question:
How many male students (sex is 'M') are allergic to any type of food?
Additional table information: table: allergy_1

Answer: SELECT COUNT(*) FROM Student WHERE sex = 'M' AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = 'food')


Question:
What are the names of cities that are in the county with the most police officers?
Additional table information: table: county_public_safety

Answer: SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1)


Question:
Which customers made orders between 2009-01-01 and 2010-01-01? Find their names.
Additional table information: table: tracking_orders

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


Question:
Find the name of the company that has the least number of phone models. List the company name and the number of phone model produced by that company.
Additional table information: table: phone_1

Answer: SELECT Company_name, COUNT(*) FROM phone GROUP BY Company_name ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Show locations and nicknames of schools.
Additional table information: table: school_player

Answer: SELECT T1.Location, T2.Nickname FROM school AS T1 JOIN school_details AS T2 ON T1.School_ID = T2.School_ID


Question:
Which city lives most of staffs? List the city name and number of staffs.
Additional table information: table: driving_school

Answer: SELECT T1.city, COUNT(*) FROM Addresses AS T1 JOIN Staff AS T2 ON T1.address_id = T2.staff_address_id GROUP BY T1.city ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the description of the service type which offers both the photo product and the film product?
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT T1.Service_Type_Description FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Name = 'photo' INTERSECT SELECT T1.Service_Type_Description FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Name = 'film'


Question:
What is the last name and office of the professor from the history department?
Additional table information: table: college_1

Answer: SELECT T1.emp_lname, T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T2.dept_code = T3.dept_code WHERE T3.dept_name = 'History'


Question:
What are the distinct years in which the competitions type is not 'Tournament'?
Additional table information: table: sports_competition

Answer: SELECT DISTINCT YEAR FROM competition WHERE Competition_type <> 'Tournament'


Question:
Show the dates, places, and names of events in descending order of the attendance.
Additional table information: table: news_report

Answer: SELECT Date, Name, venue FROM event ORDER BY Event_Attendance DESC


Question:
Show the location name and code with the least documents.
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT T2.location_name, T1.location_code FROM Document_locations AS T1 JOIN Ref_locations AS T2 ON T1.location_code = T2.location_code GROUP BY T1.location_code ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
What are the names of the ships  that are from either the US or the UK?
Additional table information: table: ship_mission

Answer: SELECT Name FROM ship WHERE Nationality = 'United States' OR Nationality = 'United Kingdom'


Question:
Find the phone numbers of customers using the most common policy type among the available policies.
Additional table information: table: insurance_fnol

Answer: SELECT customer_phone FROM available_policies WHERE policy_type_code = (SELECT policy_type_code FROM available_policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1)


Question:
List the names of courses in alphabetical order?
Additional table information: table: student_assessment

Answer: SELECT course_name FROM courses ORDER BY course_name NULLS FIRST


Question:
What is the mail date of the document with id 7?
Additional table information: table: cre_Doc_Control_Systems

Answer: SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7


Question:
Please list all songs in volumes in ascending alphabetical order.
Additional table information: table: music_4

Answer: SELECT Song FROM volume ORDER BY Song NULLS FIRST


Question:
A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size.
Additional table information: table: store_1

Answer: SELECT billing_country, SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8


Question:
Show each student's first name and last name.
Additional table information: table: student_1

Answer: SELECT DISTINCT firstname, lastname FROM list


Question:
What is the name and detail of each staff member?
Additional table information: table: cre_Theme_park

Answer: SELECT Name, Other_Details FROM Staff


Question:
What are the names of wrestlers and their teams in elimination, ordered descending by days held?
Additional table information: table: wrestler

Answer: SELECT T2.Name, T1.Team FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC


Question:
What is the total amount of moeny paid by the customer Carole Bernhard?
Additional table information: table: driving_school

Answer: SELECT SUM(T1.amount_payment) FROM Customer_Payments AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Carole' AND T2.last_name = 'Bernhard'


Question:
Show all advisors and corresponding number of students.
Additional table information: table: allergy_1

Answer: SELECT advisor, COUNT(*) FROM Student GROUP BY advisor


Question:
Find the full name of the customer with the email 'luisg@embraer.com.br'.
Additional table information: table: chinook_1

Answer: SELECT FirstName, LastName FROM CUSTOMER WHERE Email = 'luisg@embraer.com.br'


Question:
Which address has both members younger than 30 and members older than 40?
Additional table information: table: coffee_shop

Answer: SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40


Question:
Show the details and star ratings of the 3 least expensive hotels.
Additional table information: table: cre_Theme_park

Answer: SELECT other_hotel_details, star_rating_code FROM HOTELS ORDER BY price_range ASC NULLS FIRST LIMIT 3


Question:
What are the names of tracks that contain the the word you in them?
Additional table information: table: chinook_1

Answer: SELECT Name FROM TRACK WHERE Name LIKE '%you%'


Question:
List the email addresses of the drama workshop groups located in Alaska state.
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT T2.Store_Email_Address FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID WHERE T1.State_County = 'Alaska'


Question:
List the companies and the investors of entrepreneurs.
Additional table information: table: entrepreneur

Answer: SELECT Company, Investor FROM entrepreneur


Question:
Retrieve the title of the paper that has the largest number of authors.
Additional table information: table: icfp_1

Answer: SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT MAX(authorder) FROM authorship)


Question:
What are the names of all employees who are not certified to fly Boeing 737-800s?
Additional table information: table: flight_1

Answer: SELECT name FROM Employee EXCEPT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = 'Boeing 737-800'


Question:
Find the names of swimmers who has a result of 'win'.
Additional table information: table: swimming

Answer: SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win'


Question:
What are the different ages of editors? Show each age along with the number of editors of that age.
Additional table information: table: journal_committee

Answer: SELECT Age, COUNT(*) FROM editor GROUP BY Age


Question:
What are the famous titles of artists who do not have any volumes?
Additional table information: table: music_4

Answer: SELECT Famous_Title FROM artist WHERE NOT Artist_ID IN (SELECT Artist_ID FROM volume)


Question:
How many students, on average, does each college have enrolled?
Additional table information: table: soccer_2

Answer: SELECT AVG(enr) FROM College


Question:
What are the types of competition that have most 5 competitions for that type?
Additional table information: table: sports_competition

Answer: SELECT Competition_type FROM competition GROUP BY Competition_type HAVING COUNT(*) <= 5


Question:
Find the name, city, and country of the airport that has the highest latitude.
Additional table information: table: flight_4

Answer: SELECT name, city, country FROM airports ORDER BY elevation DESC LIMIT 1


Question:
What are the distinct billing countries of the invoices?
Additional table information: table: chinook_1

Answer: SELECT DISTINCT (BillingCountry) FROM INVOICE


Question:
What are the enrollments of schools whose denomination is not 'Catholic'?
Additional table information: table: school_player

Answer: SELECT Enrollment FROM school WHERE Denomination <> 'Catholic'


Question:
Show the names of clubs that have players with position 'Right Wing'.
Additional table information: table: sports_competition

Answer: SELECT T1.name FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T2.Position = 'Right Wing'


Question:
Find the titles of all movies that have no ratings.
Additional table information: table: movie_1

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


Question:
Which team offers the lowest average salary? Give me the name and id of the team.
Additional table information: table: baseball_1

Answer: SELECT T1.name, T1.team_id FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id ORDER BY AVG(T2.salary) ASC NULLS FIRST LIMIT 1


Question:
What are the names and year of joining for artists that do not have the country 'United States'?
Additional table information: table: theme_gallery

Answer: SELECT name, year_join FROM artist WHERE country <> 'United States'


Question:
What are the distinct unit prices of all tracks?
Additional table information: table: chinook_1

Answer: SELECT DISTINCT (UnitPrice) FROM TRACK


Question:
Find the location and all games score of the school that has Clemson as its team name.
Additional table information: table: university_basketball

Answer: SELECT t2.All_Games, t1.location FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id WHERE team_name = 'Clemson'


Question:
What is the decor of room Recluse and defiance?
Additional table information: table: inn_1

Answer: SELECT decor FROM Rooms WHERE roomName = 'Recluse and defiance'


Question:
What are the states with colleges that have enrollments less than the some other college?
Additional table information: table: soccer_2

Answer: SELECT DISTINCT state FROM college WHERE enr < (SELECT MAX(enr) FROM college)


Question:
What are the details of the three most expensive hotels?
Additional table information: table: cre_Theme_park

Answer: SELECT other_hotel_details FROM HOTELS ORDER BY price_range DESC LIMIT 3


Question:
Find the detail of products whose detail contains the word 'Latte' or the word 'Americano'
Additional table information: table: customers_and_addresses

Answer: SELECT product_details FROM products WHERE product_details LIKE '%Latte%' OR product_details LIKE '%Americano%'


Question:
How many medicines were not approved by the FDA?
Additional table information: table: medicine_enzyme_interaction

Answer: SELECT COUNT(*) FROM medicine WHERE FDA_approved = 'No'


Question:
Find the name of people whose age is greater than any engineer sorted by their age.
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age > (SELECT MIN(age) FROM person WHERE job = 'engineer') ORDER BY age NULLS FIRST


Question:
What are the register ids of electoral registries that have the cross reference source system code 'Electoral' or 'Tax'?
Additional table information: table: local_govt_mdm

Answer: SELECT T1.electoral_register_id FROM Electoral_Register AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id WHERE T2.source_system_code = 'Electoral' OR T2.source_system_code = 'Tax'


Question:
What are the names of shops that do not have any devices in stock?
Additional table information: table: device

Answer: SELECT Shop_Name FROM shop WHERE NOT Shop_ID IN (SELECT Shop_ID FROM stock)


Question:
List the name and the number of enrolled student for each course.
Additional table information: table: e_learning

Answer: SELECT T1.course_name, COUNT(*) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name


Question:
Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000.
Additional table information: table: solvency_ii

Answer: SELECT Product_Type_Code FROM Products WHERE Product_Price > 4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price < 3000


Question:
What is the first and last name of the professor in biology department?
Additional table information: table: college_1

Answer: SELECT T3.EMP_FNAME, T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = 'Biology'


Question:
How many storms had death records?
Additional table information: table: storm_record

Answer: SELECT COUNT(*) FROM storm WHERE Number_Deaths > 0


Question:
Who are the players from UCLA?
Additional table information: table: match_season

Answer: SELECT Player FROM match_season WHERE College = 'UCLA'


Question:
Find the country of all appelations who have at most three wines.
Additional table information: table: wine_1

Answer: SELECT T1.County FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation GROUP BY T2.Appelation HAVING COUNT(*) <= 3


Question:
What are the official names of cities that have population over 1500 or less than 500?
Additional table information: table: farm

Answer: SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500


Question:
What is the name and distance for the aircraft that has an id of 12?
Additional table information: table: flight_1

Answer: SELECT name, distance FROM Aircraft WHERE aid = 12


Question:
Count the number of items store 1 has in stock.
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM inventory WHERE store_id = 1


Question:
Return the names of songs for which format is mp3 and resolution is below 1000.
Additional table information: table: music_1

Answer: SELECT T2.song_name FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.formats = 'mp3' INTERSECT SELECT song_name FROM song WHERE resolution < 1000


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

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


Question:
What are the names of the songs whose title has the word 'the'?
Additional table information: table: music_2

Answer: SELECT title FROM songs WHERE title LIKE '% the %'


Question:
What are the titles of films and corresponding types of market estimations?
Additional table information: table: film_rank

Answer: SELECT T1.Title, T2.Type FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID


Question:
Show the county name and population of all counties.
Additional table information: table: election

Answer: SELECT County_name, Population FROM county


Question:
Return all distinct detention type codes.
Additional table information: table: behavior_monitoring

Answer: SELECT DISTINCT detention_type_code FROM Detention


Question:
Show all distinct positions of matches.
Additional table information: table: match_season

Answer: SELECT DISTINCT POSITION FROM match_season


Question:
Return the dates of birth for entrepreneurs who have either the investor Simon Woodroffe or Peter Jones.
Additional table information: table: entrepreneur

Answer: 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:
Which counties have two or more delegates? Give me the county names.
Additional table information: table: election

Answer: SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District GROUP BY T1.County_id HAVING COUNT(*) >= 2


Question:
Show all movie titles, years, and directors, ordered by budget.
Additional table information: table: culture_company

Answer: SELECT title, YEAR, director FROM movie ORDER BY budget_million NULLS FIRST


Question:
Show the id and details of the investor that has the largest number of transactions.
Additional table information: table: tracking_share_transactions

Answer: SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the last date of the staff leaving the projects?
Additional table information: table: tracking_grants_for_research

Answer: SELECT date_to FROM Project_Staff ORDER BY date_to DESC LIMIT 1


Question:
Find the average room count of the apartments that have the 'Studio' type code.
Additional table information: table: apartment_rentals

Answer: SELECT AVG(room_count) FROM Apartments WHERE apt_type_code = 'Studio'


Question:
What are the booking start and end dates of the apartments with type code 'Duplex'?
Additional table information: table: apartment_rentals

Answer: SELECT T1.booking_start_date, T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.apt_type_code = 'Duplex'


Question:
What is the location of the party with the most hosts?
Additional table information: table: party_host

Answer: SELECT LOCATION FROM party ORDER BY Number_of_hosts DESC LIMIT 1


Question:
List all the model names sorted by their launch year.
Additional table information: table: phone_1

Answer: SELECT model_name FROM chip_model ORDER BY launch_year NULLS FIRST


Question:
Find the average prices of all products from each manufacture, and list each company's name.
Additional table information: table: manufactory_1

Answer: SELECT AVG(T1.price), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name


Question:
How many documents can one grant have at most? List the grant id and number.
Additional table information: table: tracking_grants_for_research

Answer: SELECT grant_id, COUNT(*) FROM Documents GROUP BY grant_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the name of the colleges whose enrollment is greater 18000 sorted by the college's name.
Additional table information: table: soccer_2

Answer: SELECT cName FROM College WHERE enr > 18000 ORDER BY cName NULLS FIRST


Question:
Find the names of goods that receive a rating of 10.
Additional table information: table: epinions_1

Answer: SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10


Question:
How many films are there in each category? List the genre name, genre id and the count.
Additional table information: table: sakila_1

Answer: SELECT T2.name, T1.category_id, COUNT(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id


Question:
What are the dates of the latest logon of the students with family name 'Jaskolski' or 'Langosh'?
Additional table information: table: e_learning

Answer: SELECT date_of_latest_logon FROM Students WHERE family_name = 'Jaskolski' OR family_name = 'Langosh'


Question:
Show the addresses of the buildings that have apartments with more than 2 bathrooms.
Additional table information: table: apartment_rentals

Answer: SELECT T1.building_address FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id = T2.building_id WHERE T2.bathroom_count > 2


Question:
What is the name and date of the most recent race?
Additional table information: table: formula_1

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


Question:
What is the average number of cities of markets with low film market estimate bigger than 10000?
Additional table information: table: film_rank

Answer: SELECT AVG(T2.Number_cities) FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T1.Low_Estimate > 10000


Question:
What are all role codes?
Additional table information: table: cre_Doc_Control_Systems

Answer: SELECT role_code FROM ROLES


Question:
Show the studios that have produced films with director 'Nicholas Meyer' and 'Walter Hill'.
Additional table information: table: film_rank

Answer: SELECT Studio FROM film WHERE Director = 'Nicholas Meyer' INTERSECT SELECT Studio FROM film WHERE Director = 'Walter Hill'


Question:
what are the order id and customer id of the oldest order?
Additional table information: table: tracking_orders

Answer: SELECT order_id, customer_id FROM orders ORDER BY date_order_placed NULLS FIRST LIMIT 1


Question:
Show names of actors in descending order of the year their musical is awarded.
Additional table information: table: musical

Answer: SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC


Question:
What are the average ages for male and female students?
Additional table information: table: allergy_1

Answer: SELECT AVG(age), sex FROM Student GROUP BY sex


Question:
Find the first and last name of all the teachers that teach EVELINA BROMLEY.
Additional table information: table: student_1

Answer: SELECT T2.firstname, T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.firstname = 'EVELINA' AND T1.lastname = 'BROMLEY'


Question:
What is the full name ( first name and last name ) for those employees who gets more salary than the employee whose id is 163?
Additional table information: table: hr_1

Answer: SELECT first_name, last_name FROM employees WHERE salary > (SELECT salary FROM employees WHERE employee_id = 163)


Question:
Find the year in which the least people enter hall of fame.
Additional table information: table: baseball_1

Answer: SELECT yearid FROM hall_of_fame GROUP BY yearid ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
What are the last names of customers without invoice totals exceeding 20?
Additional table information: table: chinook_1

Answer: SELECT LastName FROM CUSTOMER EXCEPT SELECT T1.LastName FROM CUSTOMER AS T1 JOIN Invoice AS T2 ON T1.CustomerId = T2.CustomerId WHERE T2.total > 20


Question:
What are the names of all directors whose movies have been reviewed by Sarah Martinez?
Additional table information: table: movie_1

Answer: SELECT DISTINCT T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Sarah Martinez'


Question:
Find the email and phone number of the customers who have never filed a complaint before.
Additional table information: table: customer_complaints

Answer: SELECT email_address, phone_number FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM complaints)


Question:
Find the famous titles of artists that do not have any volume.
Additional table information: table: music_4

Answer: SELECT Famous_Title FROM artist WHERE NOT Artist_ID IN (SELECT Artist_ID FROM volume)


Question:
Count the number of different directors.
Additional table information: table: culture_company

Answer: SELECT COUNT(DISTINCT director) FROM movie


Question:
Give the full name and customer id of the customer with the fewest accounts.
Additional table information: table: customers_card_transactions

Answer: SELECT T2.customer_first_name, T2.customer_last_name, T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1


Question:
Which bike traveled the most often in zip code 94002?
Additional table information: table: bike_1

Answer: SELECT bike_id FROM trip WHERE zip_code = 94002 GROUP BY bike_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the number of trains starting from each origin.
Additional table information: table: station_weather

Answer: SELECT origin, COUNT(*) FROM train GROUP BY origin


Question:
Which country has at most 3 stadiums listed?
Additional table information: table: swimming

Answer: SELECT country FROM stadium GROUP BY country HAVING COUNT(*) <= 3


Question:
what is the powertrain (engine/transmission) when the order year is 2000?
Additional table information: table: "vehicles"."cars"
columns: order_year, manufacturer, model, fleet_series_quantity, powertrain, fuel_propulsion

Answer: SELECT powertrain FROM "vehicles"."cars" WHERE order_year = '2000'


Question:
What is the id of the organization with the maximum number of outcomes and how many outcomes are there?
Additional table information: table: tracking_grants_for_research

Answer: SELECT T1.organisation_id, COUNT(*) FROM Projects AS T1 JOIN Project_outcomes AS T2 ON T1.project_id = T2.project_id GROUP BY T1.organisation_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find id of candidates whose assessment code is 'Pass'?
Additional table information: table: student_assessment

Answer: SELECT candidate_id FROM candidate_assessments WHERE asessment_outcome_code = 'Pass'


Question:
Which buildings have more than one company offices? Give me the building names.
Additional table information: table: company_office

Answer: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T1.building_id HAVING COUNT(*) > 1


Question:
What is the type description of the organization whose detail is listed as 'quo'?
Additional table information: table: tracking_grants_for_research

Answer: SELECT T1.organisation_type_description FROM organisation_Types AS T1 JOIN Organisations AS T2 ON T1.organisation_type = T2.organisation_type WHERE T2.organisation_details = 'quo'


Question:
What are the names of all the states with college students playing in the mid position but no goalies?
Additional table information: table: soccer_2

Answer: SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie'


Question:
Show all locations and the total number of platforms and passengers for all train stations in each location.
Additional table information: table: train_station

Answer: SELECT LOCATION, SUM(number_of_platforms), SUM(total_passengers) FROM station GROUP BY LOCATION


Question:
Show the id and details for the investors who have the top 3 number of transactions.
Additional table information: table: tracking_share_transactions

Answer: SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 3


Question:
What campus started in year 1956, has more than 200 full time students, and more than 400 students enrolled?
Additional table information: table: csu_1

Answer: 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:
Find the names of courses taught by the tutor who has personal name 'Julio'.
Additional table information: table: e_learning

Answer: SELECT T2.course_name FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T1.personal_name = 'Julio'


Question:
Who belong to the institution 'University of Oxford'? Show the first names and last names.
Additional table information: table: icfp_1

Answer: SELECT DISTINCT t1.fname, t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'University of Oxford'


Question:
Which buildings does 'Emma' manage? Give me the short names of the buildings.
Additional table information: table: apartment_rentals

Answer: SELECT building_short_name FROM Apartment_Buildings WHERE building_manager = 'Emma'


Question:
Which customer's name contains 'Alex'? Find the full name.
Additional table information: table: customers_and_addresses

Answer: SELECT customer_name FROM customers WHERE customer_name LIKE '%Alex%'


Question:
Find the address of all customers that live in Germany and have invoice.
Additional table information: table: chinook_1

Answer: SELECT DISTINCT T1.Address FROM CUSTOMER AS T1 JOIN INVOICE AS T2 ON T1.CustomerId = T2.CustomerId WHERE T1.country = 'Germany'


Question:
What is the total amount of settlement made for all the settlements?
Additional table information: table: insurance_policies

Answer: SELECT SUM(Amount_Settled) FROM Settlements


Question:
For each movie that received more than 3 reviews, what is the average rating?
Additional table information: table: movie_1

Answer: SELECT mID, AVG(stars) FROM Rating GROUP BY mID HAVING COUNT(*) >= 2


Question:
Which papers have the substring 'ML' in their titles? Return the titles of the papers.
Additional table information: table: icfp_1

Answer: SELECT title FROM papers WHERE title LIKE '%ML%'


Question:
Give me the detail and opening hour for each museum.
Additional table information: table: cre_Theme_park

Answer: SELECT T1.Museum_Details, T2.Opening_Hours FROM MUSEUMS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Museum_ID = T2.Tourist_Attraction_ID


Question:
What is the number of technicians?
Additional table information: table: machine_repair

Answer: SELECT COUNT(*) FROM technician


Question:
Which trip started from the station with the largest dock count? Give me the trip id.
Additional table information: table: bike_1

Answer: SELECT T1.id FROM trip AS T1 JOIN station AS T2 ON T1.start_station_id = T2.id ORDER BY T2.dock_count DESC LIMIT 1


Question:
Return the claim start date for the claims whose claimed amount is no more than the average
Additional table information: table: insurance_policies

Answer: SELECT Date_Claim_Made FROM Claims WHERE Amount_Settled <= (SELECT AVG(Amount_Settled) FROM Claims)


Question:
Find the titles and studios of the films that are produced by some film studios that contained the word 'Universal'.
Additional table information: table: film_rank

Answer: SELECT title, Studio FROM film WHERE Studio LIKE '%Universal%'


Question:
How many male (sex is M) students have class senator votes in the fall election cycle?
Additional table information: table: voter_2

Answer: SELECT COUNT(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = Class_Senator_Vote WHERE T1.Sex = 'M' AND T2.Election_Cycle = 'Fall'


Question:
What are the first names of all students who live in the dorm with the most amenities?
Additional table information: table: dorm_1

Answer: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY COUNT(*) DESC LIMIT 1)


Question:
What are the different names of the genres?
Additional table information: table: store_1

Answer: SELECT DISTINCT name FROM genres


Question:
Which customers do not have a first notification of loss record? Give me the customer names.
Additional table information: table: insurance_fnol

Answer: SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id


Question:
Show the transaction type and the number of transactions.
Additional table information: table: customers_card_transactions

Answer: SELECT transaction_type, COUNT(*) FROM Financial_transactions GROUP BY transaction_type


Question:
What are the first names of the professors who do not play Canoeing or Kayaking as activities?
Additional table information: table: activity_1

Answer: SELECT lname FROM faculty WHERE rank = 'Professor' EXCEPT SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking'


Question:
Who are the top 3 players in terms of overall rating?
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id ORDER BY overall_rating DESC LIMIT 3


Question:
Show the average age for male and female students.
Additional table information: table: allergy_1

Answer: SELECT AVG(age), sex FROM Student GROUP BY sex


Question:
What is the apartment number of the apartment with the most beds?
Additional table information: table: apartment_rentals

Answer: SELECT apt_number FROM Apartments ORDER BY bedroom_count DESC LIMIT 1


Question:
What are the average amount purchased and value purchased for the supplier who supplies the most products.
Additional table information: table: department_store

Answer: SELECT AVG(total_amount_purchased), AVG(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
Which city has the highest temperature in February?
Additional table information: table: city_record

Answer: SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id ORDER BY T2.Feb DESC LIMIT 1


Question:
Show all locations with only 1 station.
Additional table information: table: train_station

Answer: SELECT LOCATION FROM station GROUP BY LOCATION HAVING COUNT(*) = 1


Question:
Return the elimination movies of wrestlers on Team Orton.
Additional table information: table: wrestler

Answer: SELECT Elimination_Move FROM Elimination WHERE Team = 'Team Orton'


Question:
What is the payment method of the customer that has purchased the least quantity of items?
Additional table information: table: customers_and_addresses

Answer: SELECT t1.payment_method FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY SUM(t3.order_quantity) NULLS FIRST LIMIT 1


Question:
Which publishers did not publish a book in 1989?
Additional table information: table: culture_company

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


Question:
How many entrepreneurs correspond to each investor?
Additional table information: table: entrepreneur

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


Question:
What are the positions of players whose average number of points scored by that position is larger than 20?
Additional table information: table: sports_competition

Answer: SELECT POSITION FROM player GROUP BY name HAVING AVG(Points) >= 20


Question:
Which city is post code 255 located in?
Additional table information: table: customers_and_addresses

Answer: SELECT city FROM addresses WHERE zip_postcode = 255


Question:
What are the job ids for jobs done more than once for a period of more than 300 days?
Additional table information: table: hr_1

Answer: SELECT job_id FROM job_history WHERE end_date - start_date > 300 GROUP BY job_id HAVING COUNT(*) >= 2


Question:
What are the names of all pilots listed by descending age?
Additional table information: table: aircraft

Answer: SELECT Name FROM pilot ORDER BY Age DESC


Question:
What is the total share (in percent) of all the channels owned by CCTV?
Additional table information: table: program_share

Answer: SELECT SUM(Share_in_percent) FROM channel WHERE OWNER = 'CCTV'


Question:
What are the names of regions that were affected by the storm in which the most people died?
Additional table information: table: storm_record

Answer: SELECT T2.region_name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id ORDER BY T3.Number_Deaths DESC LIMIT 1


Question:
List all statement ids and statement details.
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT STATEMENT_ID, statement_details FROM Statements


Question:
How many markets have number of cities smaller than 300?
Additional table information: table: film_rank

Answer: SELECT COUNT(*) FROM market WHERE Number_cities < 300


Question:
display the job title of jobs which minimum salary is greater than 9000.
Additional table information: table: hr_1

Answer: SELECT job_title FROM jobs WHERE min_salary > 9000


Question:
For each party, return the name of the party and the number of delegates from that party.
Additional table information: table: election

Answer: SELECT T2.Party, COUNT(*) FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party


Question:
What are the first names of the teachers who teach grade 1?
Additional table information: table: student_1

Answer: SELECT DISTINCT T2.firstname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE grade = 1


Question:
What are the titles of all movies that have between 3 and 5 stars?
Additional table information: table: movie_1

Answer: SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5


Question:
What are the titles of courses that are in the Statistics department but not the Psychology department?
Additional table information: table: college_2

Answer: SELECT title FROM course WHERE dept_name = 'Statistics' EXCEPT SELECT title FROM course WHERE dept_name = 'Psychology'


Question:
List the names of counties in descending order of population.
Additional table information: table: county_public_safety

Answer: SELECT Name FROM county_public_safety ORDER BY Population DESC


Question:
What is the last name of the musician that have produced the most number of songs?
Additional table information: table: music_2

Answer: SELECT T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId GROUP BY lastname ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many songs were released for each format?
Additional table information: table: music_1

Answer: SELECT COUNT(*), formats FROM files GROUP BY formats


Question:
Report the first name and last name of all the students.
Additional table information: table: student_1

Answer: SELECT DISTINCT firstname, lastname FROM list


Question:
What is the first, last name, gpa of the youngest one among students whose GPA is above 3?
Additional table information: table: college_1

Answer: SELECT stu_fname, stu_lname, stu_gpa FROM student WHERE stu_gpa > 3 ORDER BY stu_dob DESC LIMIT 1


Question:
Return the ids of the two department store chains with the most department stores.
Additional table information: table: department_store

Answer: SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY COUNT(*) DESC LIMIT 2


Question:
Find the oldest log id and its corresponding problem id.
Additional table information: table: tracking_software_problems

Answer: SELECT problem_log_id, problem_id FROM problem_log ORDER BY log_entry_date NULLS FIRST LIMIT 1


Question:
What are the employee ids for employees who have held two or more jobs?
Additional table information: table: hr_1

Answer: SELECT employee_id FROM job_history GROUP BY employee_id HAVING COUNT(*) >= 2


Question:
How many airports haven't the pilot 'Thompson' driven an aircraft?
Additional table information: table: flight_company

Answer: SELECT COUNT(*) FROM airport WHERE NOT id IN (SELECT airport_id FROM flight WHERE pilot = 'Thompson')


Question:
How many different types of transactions are there?
Additional table information: table: customers_card_transactions

Answer: SELECT COUNT(DISTINCT transaction_type) FROM Financial_Transactions


Question:
Which authors have last name 'Ueno'? List their first names.
Additional table information: table: icfp_1

Answer: SELECT fname FROM authors WHERE lname = 'Ueno'


Question:
Find the city where the most customers live.
Additional table information: table: customers_and_addresses

Answer: SELECT t3.city FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id GROUP BY t3.city ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the average population of all counties.
Additional table information: table: election

Answer: SELECT AVG(Population) FROM county


Question:
find the ids of reviewers who did not give 4 star.
Additional table information: table: movie_1

Answer: SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4


Question:
Count the number of colors that are not used in any products.
Additional table information: table: products_gen_characteristics

Answer: SELECT COUNT(*) FROM Ref_colors WHERE NOT color_code IN (SELECT color_code FROM products)


Question:
Show the album names, ids and the number of tracks for each album.
Additional table information: table: chinook_1

Answer: SELECT T1.Title, T2.AlbumID, COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID


Question:
What is the payment method code used by the most orders?
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT payment_method_code FROM INVOICES GROUP BY payment_method_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the first and last name of students whose age is younger than the average age.
Additional table information: table: dorm_1

Answer: SELECT fname, lname FROM student WHERE age < (SELECT AVG(age) FROM student)


Question:
Which cities have served as host cities more than once? Return me their GDP and population.
Additional table information: table: city_record

Answer: SELECT t1.gdp, t1.Regional_Population FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY t2.Host_City HAVING COUNT(*) > 1


Question:
What are all the fault descriptions and the fault status of all the faults recoreded in the logs?
Additional table information: table: assets_maintenance

Answer: SELECT T1.fault_description, T2.fault_status FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id


Question:
How many different players trained for more than 1000 hours?
Additional table information: table: soccer_2

Answer: SELECT COUNT(*) FROM Player WHERE HS > 1000


Question:
How many states have smaller colleges than average?
Additional table information: table: soccer_2

Answer: SELECT COUNT(DISTINCT state) FROM college WHERE enr < (SELECT AVG(enr) FROM college)


Question:
Report the number of students in each classroom.
Additional table information: table: student_1

Answer: SELECT classroom, COUNT(*) FROM list GROUP BY classroom


Question:
What are the names of customers who have both savings and checking accounts?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'


Question:
List the id of students who registered some courses and the number of their registered courses?
Additional table information: table: student_assessment

Answer: SELECT T1.student_id, COUNT(*) FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id


Question:
What are the ids for transactions that have an amount greater than the average amount of a transaction?
Additional table information: table: customers_and_invoices

Answer: SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM Financial_transactions)


Question:
What are the names of cities, as well as the names of the counties they correspond to?
Additional table information: table: county_public_safety

Answer: SELECT T1.Name, T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID


Question:
Return the id of the store with the most customers.
Additional table information: table: sakila_1

Answer: SELECT store_id FROM customer GROUP BY store_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
How much is the track Fast As a Shark?
Additional table information: table: store_1

Answer: SELECT unit_price FROM tracks WHERE name = 'Fast As a Shark'


Question:
What is the id of the order which has the most items?
Additional table information: table: tracking_orders

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


Question:
What is the total horses record for each farm, sorted ascending?
Additional table information: table: farm

Answer: SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC NULLS FIRST


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

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


Question:
What is the average age of students who have city code 'NYC' and have secretary votes for the spring election cycle?
Additional table information: table: voter_2

Answer: SELECT AVG(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = SECRETARY_Vote WHERE T1.city_code = 'NYC' AND T2.Election_Cycle = 'Spring'


Question:
What are the id and first name of the student whose addresses have the highest average monthly rental?
Additional table information: table: behavior_monitoring

Answer: SELECT T1.student_id, T2.first_name FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY AVG(monthly_rental) DESC LIMIT 1


Question:
Show all information about each body builder.
Additional table information: table: body_builder

Answer: SELECT * FROM body_builder


Question:
What are the total enrollments of universities of each affiliation type?
Additional table information: table: university_basketball

Answer: SELECT SUM(enrollment), affiliation FROM university GROUP BY affiliation


Question:
What are the ids and names of department stores with both marketing and managing departments?
Additional table information: table: department_store

Answer: SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = 'marketing' INTERSECT SELECT T2.dept_store_id, T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = 'managing'


Question:
Show the start dates and end dates of all the apartment bookings made by guests with gender code 'Female'.
Additional table information: table: apartment_rentals

Answer: SELECT T1.booking_start_date, T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id = T2.guest_id WHERE T2.gender_code = 'Female'


Question:
Show each county along with the number of schools and total enrollment in each county.
Additional table information: table: school_finance

Answer: SELECT county, COUNT(*), SUM(enrollment) FROM school GROUP BY county


Question:
What are the positions and teams of pilots?
Additional table information: table: pilot_record

Answer: SELECT POSITION, Team FROM pilot


Question:
What are the product ids and color descriptions for products with two or more characteristics?
Additional table information: table: products_gen_characteristics

Answer: SELECT t1.product_id, t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code JOIN product_characteristics AS t3 ON t1.product_id = t3.product_id GROUP BY t1.product_id HAVING COUNT(*) >= 2


Question:
What is the type of video game Call of Destiny.
Additional table information: table: game_1

Answer: SELECT gtype FROM Video_games WHERE gname = 'Call of Destiny'


Question:
What are the card numbers, names, and hometowns of every member ordered by descending level?
Additional table information: table: shop_membership

Answer: SELECT card_number, name, hometown FROM member ORDER BY LEVEL DESC


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

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


Question:
What are the distinct last names of the students who have class president votes?
Additional table information: table: voter_2

Answer: SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.CLASS_President_VOTE


Question:
Find the student ID and middle name for all the students with at most two enrollments.
Additional table information: table: e_learning

Answer: SELECT T1.student_id, T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) <= 2


Question:
Find the first and last name of the author(s) who wrote the paper 'Nameless, Painless'.
Additional table information: table: icfp_1

Answer: SELECT t1.fname, t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title = 'Nameless ,  Painless'


Question:
What is the membership card held by both members living in Hartford and ones living in Waterbury address?
Additional table information: table: coffee_shop

Answer: SELECT membership_card FROM member WHERE address = 'Hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'Waterbury'


Question:
What are the distinct salaries of all instructors who earned less than the maximum salary?
Additional table information: table: college_2

Answer: SELECT DISTINCT salary FROM instructor WHERE salary < (SELECT MAX(salary) FROM instructor)


Question:
For each product type, return the maximum and minimum price.
Additional table information: table: department_store

Answer: SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code


Question:
When was the document named 'Marry CV' stored? Give me the date.
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT date_stored FROM All_documents WHERE Document_name = 'Marry CV'


Question:
What is the count of distinct employees with certificates?
Additional table information: table: flight_1

Answer: SELECT COUNT(DISTINCT eid) FROM Certificate


Question:
Return the full names and salaries of employees with null commissions.
Additional table information: table: hr_1

Answer: SELECT first_name, last_name, salary FROM employees WHERE commission_pct = 'null'


Question:
What are the flight numbers for the aircraft Airbus A340-300?
Additional table information: table: flight_1

Answer: SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = 'Airbus A340-300'


Question:
What are the names and ids of the different albums, and how many tracks are on each?
Additional table information: table: chinook_1

Answer: SELECT T1.Title, T2.AlbumID, COUNT(*) FROM ALBUM AS T1 JOIN TRACK AS T2 ON T1.AlbumId = T2.AlbumId GROUP BY T2.AlbumID


Question:
How many faculty members does each building have? List the result with the name of the building.
Additional table information: table: activity_1

Answer: SELECT building, COUNT(*) FROM Faculty GROUP BY building


Question:
Find the different first names and cities of the students who have allergy to milk or cat.
Additional table information: table: allergy_1

Answer: SELECT DISTINCT T1.fname, T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = 'Milk' OR T2.Allergy = 'Cat'


Question:
How many transaction does each account have? Show the number and account id.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*), account_id FROM Financial_transactions


Question:
List the number of invoices from Chicago, IL.
Additional table information: table: store_1

Answer: SELECT COUNT(*) FROM invoices WHERE billing_city = 'Chicago' AND billing_state = 'IL'


Question:
What is the maximum Online Mendelian Inheritance in Man (OMIM) value of the enzymes?
Additional table information: table: medicine_enzyme_interaction

Answer: SELECT MAX(OMIM) FROM enzyme


Question:
Show the location codes with at least 3 documents.
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT location_code FROM Document_locations GROUP BY location_code HAVING COUNT(*) >= 3


Question:
List ids for all student who are on scholarship.
Additional table information: table: game_1

Answer: SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'


Question:
Show names of companies and that of employees in descending order of number of years working for that employee.
Additional table information: table: company_employee

Answer: SELECT T3.Name, T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID ORDER BY T1.Year_working NULLS FIRST


Question:
Find the number of female students (with F sex) living in Smith Hall
Additional table information: table: dorm_1

Answer: SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'


Question:
What instruments does the the song 'Le Pop' use?
Additional table information: table: music_2

Answer: SELECT instrument FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = 'Le Pop'


Question:
How many video games exist?
Additional table information: table: game_1

Answer: SELECT COUNT(*) FROM Video_games


Question:
Show the locations that have both performances with more than 2000 attendees and performances with less than 1000 attendees.
Additional table information: table: performance_attendance

Answer: SELECT LOCATION FROM performance WHERE Attendance > 2000 INTERSECT SELECT LOCATION FROM performance WHERE Attendance < 1000


Question:
Find the emails of parties with the most popular party form.
Additional table information: table: e_government

Answer: SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id = t2.party_id WHERE t2.form_id = (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
Give the names of people who did not participate in the candidate election.
Additional table information: table: candidate_poll

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


Question:
Give the name of the highest paid instructor.
Additional table information: table: college_2

Answer: SELECT name FROM instructor ORDER BY salary DESC LIMIT 1


Question:
Find the id and name of the staff who has been assigned for the shortest period.
Additional table information: table: department_store

Answer: SELECT T1.staff_id, T1.staff_name FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY date_assigned_to - date_assigned_from NULLS FIRST LIMIT 1


Question:
Show all distinct product categories along with the number of mailshots in each category.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT product_category, COUNT(*) FROM mailshot_campaigns GROUP BY product_category


Question:
What is the description of the restaurant type Sandwich?
Additional table information: table: restaurant_1

Answer: SELECT ResTypeDescription FROM Restaurant_Type WHERE ResTypeName = 'Sandwich'


Question:
What is the first name of students who got grade C in any class?
Additional table information: table: college_1

Answer: SELECT DISTINCT stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num WHERE enroll_grade = 'C'


Question:
What are the last name and office of all history professors?
Additional table information: table: college_1

Answer: SELECT T1.emp_lname, T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T2.dept_code = T3.dept_code WHERE T3.dept_name = 'History'


Question:
List the text of all tweets in the order of date.
Additional table information: table: twitter_1

Answer: SELECT text FROM tweets ORDER BY createdate NULLS FIRST


Question:
Show the name and phone for customers with a mailshot with outcome code 'No Response'.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT T1.customer_name, T1.customer_phone FROM customers AS T1 JOIN mailshot_customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.outcome_code = 'No Response'


Question:
How many players did Boston Red Stockings have in 2000?
Additional table information: table: baseball_1

Answer: SELECT COUNT(*) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2000


Question:
How long is the total lesson time taught by staff with first name as Janessa and last name as Sawayn?
Additional table information: table: driving_school

Answer: SELECT SUM(lesson_time) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Janessa' AND T2.last_name = 'Sawayn'


Question:
What are the names of banks in the state of New York?
Additional table information: table: loan_1

Answer: SELECT bname FROM bank WHERE state = 'New York'


Question:
Please show the songs that have result 'nominated' at music festivals.
Additional table information: table: music_4

Answer: SELECT T2.Song FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T1.Result = 'Nominated'


Question:
What are the account ids, customer ids, and account names for all the accounts?
Additional table information: table: customers_card_transactions

Answer: SELECT account_id, customer_id, account_name FROM Accounts


Question:
display all the information of those employees who did not have any job in the past.
Additional table information: table: hr_1

Answer: SELECT * FROM employees WHERE NOT employee_id IN (SELECT employee_id FROM job_history)


Question:
Return the number of accounts that the customer with the first name Art and last name Turcotte has.
Additional table information: table: customers_card_transactions

Answer: SELECT COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Art' AND T2.customer_last_name = 'Turcotte'


Question:
How many invoices do we have?
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Invoices


Question:
Find the names of all instructors whose name includes the substring “dar”.
Additional table information: table: college_2

Answer: SELECT name FROM instructor WHERE name LIKE '%dar%'


Question:
What is the minimum and maximum number of bathrooms of all the apartments?
Additional table information: table: apartment_rentals

Answer: SELECT MIN(bathroom_count), MAX(bathroom_count) FROM Apartments


Question:
List all public schools and their locations.
Additional table information: table: university_basketball

Answer: SELECT school, LOCATION FROM university WHERE affiliation = 'Public'


Question:
find the name of pilots who did not win the matches held in the country of Australia.
Additional table information: table: aircraft

Answer: SELECT name FROM pilot WHERE NOT pilot_id IN (SELECT Winning_Pilot FROM MATCH WHERE country = 'Australia')


Question:
What are the student IDs and middle names of the students enrolled in at most two courses?
Additional table information: table: e_learning

Answer: SELECT T1.student_id, T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) <= 2


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

Answer: 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:
List the names and phone numbers of all the distinct suppliers who supply red jeans.
Additional table information: table: department_store

Answer: SELECT DISTINCT T1.supplier_name, T1.supplier_phone FROM suppliers AS T1 JOIN product_suppliers AS T2 ON T1.supplier_id = T2.supplier_id JOIN products AS T3 ON T2.product_id = T3.product_id WHERE T3.product_name = 'red jeans'


Question:
What are the names of the songs that do not have back vocals?
Additional table information: table: music_2

Answer: SELECT DISTINCT title FROM vocals AS t1 JOIN songs AS t2 ON t1.songid = t2.songid EXCEPT SELECT t2.title FROM vocals AS t1 JOIN songs AS t2 ON t1.songid = t2.songid WHERE TYPE = 'back'


Question:
Which customers have an insurance policy with the type code 'Deputy' or 'Uniform'? Return the customer details.
Additional table information: table: insurance_and_eClaims

Answer: SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = 'Deputy' OR t1.policy_type_code = 'Uniform'


Question:
Of complaints with the type code 'Product Failure', how many had each different status code?
Additional table information: table: customer_complaints

Answer: SELECT complaint_status_code, COUNT(*) FROM complaints WHERE complaint_type_code = 'Product Failure' GROUP BY complaint_status_code


Question:
Find the name of the teacher who teaches the largest number of students.
Additional table information: table: student_1

Answer: SELECT T2.firstname, T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom GROUP BY T2.firstname, T2.lastname ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the titles of the papers the author 'Stephanie Weirich' wrote.
Additional table information: table: icfp_1

Answer: SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t1.fname = 'Stephanie' AND t1.lname = 'Weirich'


Question:
Find the first and last name of the staff members who reported problems from the product 'rem' but not 'aut'?
Additional table information: table: tracking_software_problems

Answer: SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = 'rem' EXCEPT SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1, product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = 'aut'


Question:
What is the most common status across all cities?
Additional table information: table: farm

Answer: SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the name of the bank branch that has lended the largest total amount in loans, specifically to customers with credit scores below 100?
Additional table information: table: loan_1

Answer: SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY SUM(T1.amount) DESC LIMIT 1


Question:
What is the total budget amount for school 'Glenn' in all years?
Additional table information: table: school_finance

Answer: SELECT SUM(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'


Question:
Which role is most common for the staff?
Additional table information: table: tracking_grants_for_research

Answer: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the average ticket sales gross in dollars of films?
Additional table information: table: film_rank

Answer: SELECT AVG(Gross_in_dollar) FROM film


Question:
List all media types.
Additional table information: table: store_1

Answer: SELECT name FROM media_types


Question:
What are the dates of the orders made by the customer named 'Jeramie'?
Additional table information: table: tracking_orders

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


Question:
List the names of countries whose language is not 'German'.
Additional table information: table: roller_coaster

Answer: SELECT Name FROM country WHERE Languages <> 'German'


Question:
What is the party of the youngest people?
Additional table information: table: debate

Answer: SELECT Party FROM people ORDER BY Age ASC NULLS FIRST LIMIT 1


Question:
Show the number of documents.
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT COUNT(*) FROM Documents


Question:
Which category does the product named 'flax' belong to?
Additional table information: table: products_gen_characteristics

Answer: SELECT product_category_code FROM products WHERE product_name = 'flax'


Question:
What are the names of the different artists from Bangladesh who never received a rating higher than a 7?
Additional table information: table: music_1

Answer: SELECT DISTINCT artist_name FROM artist WHERE country = 'Bangladesh' EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 7


Question:
What are the statuses and average populations of each city?
Additional table information: table: farm

Answer: SELECT Status, AVG(Population) FROM city GROUP BY Status


Question:
What are all the employee ids and the names of the countries in which they work?
Additional table information: table: hr_1

Answer: SELECT T1.employee_id, T4.country_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id JOIN countries AS T4 ON T3.country_id = T4.country_id


Question:
What are the names of students who took a course in the Fall of 2003?
Additional table information: table: college_2

Answer: SELECT name FROM student WHERE id IN (SELECT id FROM takes WHERE semester = 'Fall' AND YEAR = 2003)


Question:
Show publishers that have more than one publication.
Additional table information: table: book_2

Answer: SELECT Publisher FROM publication GROUP BY Publisher HAVING COUNT(*) > 1


Question:
Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products.
Additional table information: table: department_store

Answer: SELECT AVG(total_amount_purchased), AVG(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
Show the nations that have both hosts older than 45 and hosts younger than 35.
Additional table information: table: party_host

Answer: SELECT Nationality FROM HOST WHERE Age > 45 INTERSECT SELECT Nationality FROM HOST WHERE Age < 35


Question:
What are the headquarters that have both a company in the banking and 'oil and gas' industries?
Additional table information: table: gas_company

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


Question:
What is the name of the instructor who advises the student with the greatest number of total credits?
Additional table information: table: college_2

Answer: SELECT T2.name FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id ORDER BY T3.tot_cred DESC LIMIT 1


Question:
For each distinct product name, show its average product price.
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT Product_Name, AVG(Product_Price) FROM PRODUCTS GROUP BY Product_Name


Question:
What are the details of the car with id 1?
Additional table information: table: driving_school

Answer: SELECT vehicle_details FROM Vehicles WHERE vehicle_id = 1


Question:
How many states have a college with more students than average?
Additional table information: table: soccer_2

Answer: SELECT COUNT(DISTINCT state) FROM college WHERE enr > (SELECT AVG(enr) FROM college)


Question:
What are the ids of the students who registered for course 301?
Additional table information: table: student_assessment

Answer: SELECT student_id FROM student_course_attendance WHERE course_id = 301


Question:
For each faculty rank, show the number of faculty members who have it.
Additional table information: table: activity_1

Answer: SELECT rank, COUNT(*) FROM Faculty GROUP BY rank


Question:
Return the phone numbers of employees with salaries between 8000 and 12000.
Additional table information: table: hr_1

Answer: SELECT phone_number FROM employees WHERE salary BETWEEN 8000 AND 12000


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

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


Question:
What is the average number of votes of representatives from party 'Republican'?
Additional table information: table: election_representative

Answer: SELECT AVG(T1.Votes) FROM election AS T1 JOIN representative AS T2 ON T1.Representative_ID = T2.Representative_ID WHERE T2.Party = 'Republican'


Question:
Find the checking balance of the accounts whose savings balance is higher than the average savings balance.
Additional table information: table: small_bank_1

Answer: SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT AVG(balance) FROM savings))


Question:
What are the ids of courses without prerequisites?
Additional table information: table: college_2

Answer: SELECT course_id FROM course EXCEPT SELECT course_id FROM prereq


Question:
What is average salary of the players in the team named 'Boston Red Stockings' ?
Additional table information: table: baseball_1

Answer: SELECT AVG(T1.salary) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings'


Question:
Find the last names of teachers who are not involved in any detention.
Additional table information: table: behavior_monitoring

Answer: SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id = T2.teacher_id


Question:
Which teams had more than 3 eliminations?
Additional table information: table: wrestler

Answer: SELECT Team FROM elimination GROUP BY Team HAVING COUNT(*) > 3


Question:
What is the total point count of the youngest gymnast?
Additional table information: table: gymnast

Answer: SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Age ASC NULLS FIRST LIMIT 1


Question:
Find the name and checking balance of the account with the lowest savings balance.
Additional table information: table: small_bank_1

Answer: SELECT T1.name, T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T3.balance NULLS FIRST LIMIT 1


Question:
Find the official names of cities with population bigger than 1500 or smaller than 500.
Additional table information: table: farm

Answer: SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500


Question:
List the name of all playlist.
Additional table information: table: store_1

Answer: SELECT name FROM playlists


Question:
What is the average amount of items ordered in each order?
Additional table information: table: customers_and_addresses

Answer: SELECT AVG(order_quantity) FROM order_items


Question:
Give the different positions of players who play for the country with the capital Dublin.
Additional table information: table: match_season

Answer: SELECT DISTINCT T2.Position FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T1.Capital = 'Dublin'


Question:
Find the last names of the members of the club 'Bootup Baltimore'.
Additional table information: table: club_1

Answer: SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = 'Bootup Baltimore'


Question:
What are the ids and names for each of the documents?
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT document_id, document_name FROM Documents


Question:
What are the names and salaries of instructors who advises students in the History department?
Additional table information: table: college_2

Answer: SELECT T2.name, T2.salary FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'History'


Question:
Find the founder of the company whose name begins with the letter 'S'.
Additional table information: table: manufactory_1

Answer: SELECT founder FROM manufacturers WHERE name LIKE 'S%'


Question:
What is the match id of the competition called '1994 FIFA World Cup qualification'?
Additional table information: table: city_record

Answer: SELECT match_id FROM MATCH WHERE competition = '1994 FIFA World Cup qualification'


Question:
How many different cities do people originate from?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT city) FROM Person


Question:
List the names and emails of customers who payed by Visa card.
Additional table information: table: customer_deliveries

Answer: SELECT customer_email, customer_name FROM customers WHERE payment_method = 'Visa'


Question:
List all open years when at least two shops are opened.
Additional table information: table: shop_membership

Answer: SELECT open_year FROM branch GROUP BY open_year HAVING COUNT(*) >= 2


Question:
What are the titles for courses with two prerequisites?
Additional table information: table: college_2

Answer: SELECT T1.title FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING COUNT(*) = 2


Question:
What are the region names affected by the storm with a number of deaths of least 10?
Additional table information: table: storm_record

Answer: SELECT T2.region_name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T3.number_deaths >= 10


Question:
Who is the delegate of district 1 in the elections?
Additional table information: table: election

Answer: SELECT Delegate FROM election WHERE District = 1


Question:
What is the email and phone number of Astrid Gruber the customer?
Additional table information: table: store_1

Answer: SELECT email, phone FROM customers WHERE first_name = 'Astrid' AND last_name = 'Gruber'


Question:
In how many different cities are banks located?
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT city) FROM bank