Question:
How many settlements were made on the claim with the most recent claim settlement date? List the number and the claim id.
Additional table information: table: insurance_policies

Answer: SELECT COUNT(*), T1.claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY T1.Date_Claim_Settled DESC LIMIT 1


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

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


Question:
Who is the friend of Zach with longest year relationship?
Additional table information: table: network_2

Answer: SELECT friend FROM PersonFriend WHERE name = 'Zach' AND YEAR = (SELECT MAX(YEAR) FROM PersonFriend WHERE name = 'Zach')


Question:
List all product names in ascending order of price.
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT Product_Name FROM Products ORDER BY Product_Price ASC NULLS FIRST


Question:
Find the name of the user who has the largest number of followers.
Additional table information: table: twitter_1

Answer: SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1


Question:
What is the department name of the students with lowest gpa belongs to?
Additional table information: table: college_1

Answer: SELECT T2.dept_name FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code ORDER BY stu_gpa NULLS FIRST LIMIT 1


Question:
Count the number of different teams involved in match season.
Additional table information: table: match_season

Answer: SELECT COUNT(DISTINCT Team) FROM match_season


Question:
How many companies are there?
Additional table information: table: company_office

Answer: SELECT COUNT(*) FROM Companies


Question:
Find the author for each submission and list them in ascending order of submission score.
Additional table information: table: workshop_paper

Answer: SELECT Author FROM submission ORDER BY Scores ASC NULLS FIRST


Question:
What is the id of the project with least number of documents?
Additional table information: table: cre_Docs_and_Epenses

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


Question:
Return the order ids and details for orderes with two or more invoices.
Additional table information: table: customers_and_invoices

Answer: SELECT T2.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING COUNT(*) > 2


Question:
What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst?
Additional table information: table: tracking_software_problems

Answer: SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = 'Christop' AND T2.staff_last_name = 'Berge' INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = 'Ashley' AND T2.staff_last_name = 'Medhurst'


Question:
Which stadium name contains the substring 'Bank'?
Additional table information: table: game_injury

Answer: SELECT name FROM stadium WHERE name LIKE '%Bank%'


Question:
Return the dates of ceremony corresponding to music festivals that had the category 'Best Song' and result 'Awarded'.
Additional table information: table: music_4

Answer: SELECT Date_of_ceremony FROM music_festival WHERE Category = 'Best Song' AND RESULT = 'Awarded'


Question:
Show the name of technicians aged either 36 or 37
Additional table information: table: machine_repair

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


Question:
What are the first year and last year of the parties whose theme is 'Spring' or 'Teqnology'?
Additional table information: table: party_host

Answer: SELECT First_year, Last_year FROM party WHERE Party_Theme = 'Spring' OR Party_Theme = 'Teqnology'


Question:
Who are the ministers who took office after 1961 or before 1959?
Additional table information: table: party_people

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


Question:
Count the number of devices.
Additional table information: table: device

Answer: SELECT COUNT(*) FROM device


Question:
What are the SSN and names of scientists working on the project with the most hours?
Additional table information: table: scientist_1

Answer: SELECT T3.ssn, T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT MAX(hours) FROM projects)


Question:
What are all the different product names, and how many complains has each received?
Additional table information: table: customer_complaints

Answer: SELECT t1.product_name, COUNT(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name


Question:
How many aircrafts have distance between 1000 and 5000?
Additional table information: table: flight_1

Answer: SELECT COUNT(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000


Question:
Find the number of distinct amenities.
Additional table information: table: dorm_1

Answer: SELECT COUNT(*) FROM dorm_amenity


Question:
List the dates of enrollment and completion of the student with personal name 'Karson'.
Additional table information: table: e_learning

Answer: SELECT T1.date_of_enrolment, T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.personal_name = 'Karson'


Question:
What is the average price for products?
Additional table information: table: solvency_ii

Answer: SELECT AVG(Product_Price) FROM Products


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

Answer: SELECT T2.emp_fname, T1.crs_code FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num


Question:
Count the number of distinct product types.
Additional table information: table: department_store

Answer: SELECT COUNT(DISTINCT product_type_code) FROM products


Question:
Return the number of companies created by Andy.
Additional table information: table: manufactory_1

Answer: SELECT COUNT(*) FROM manufacturers WHERE founder = 'Andy'


Question:
What are the first names of student who only took one course?
Additional table information: table: college_1

Answer: SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num GROUP BY T2.stu_num HAVING COUNT(*) = 1


Question:
Please list the countries and years of film market estimations.
Additional table information: table: film_rank

Answer: SELECT T2.Country, T1.Year FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID


Question:
Find the last names of faculties in building Barton in alphabetic order.
Additional table information: table: college_3

Answer: SELECT Lname FROM FACULTY WHERE Building = 'Barton' ORDER BY Lname NULLS FIRST


Question:
What kind of decor has the least number of reservations?
Additional table information: table: inn_1

Answer: SELECT T2.decor FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T2.decor ORDER BY COUNT(T2.decor) ASC NULLS FIRST LIMIT 1


Question:
What are the different cities where students live?
Additional table information: table: student_assessment

Answer: SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id JOIN students AS T3 ON T2.person_id = T3.student_id


Question:
What is the title of the newest movie?
Additional table information: table: movie_1

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


Question:
Show the home city with the most number of drivers.
Additional table information: table: school_bus

Answer: SELECT home_city FROM driver GROUP BY home_city ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the first name and major of the students who are able to consume soy?
Additional table information: table: allergy_1

Answer: SELECT fname, major FROM Student WHERE NOT StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = 'Soy')


Question:
How many customers do we have?
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT COUNT(*) FROM CUSTOMERS


Question:
Which claims caused more than 2 settlements or have the maximum claim value? List the date the claim was made and the claim id.
Additional table information: table: insurance_policies

Answer: SELECT T1.Date_Claim_Made, T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.Claim_id HAVING COUNT(*) > 2 UNION SELECT T1.Date_Claim_Made, T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id WHERE T1.Amount_Claimed = (SELECT MAX(Amount_Claimed) FROM Claims)


Question:
Find the names of stadiums whose capacity is smaller than the average capacity.
Additional table information: table: swimming

Answer: SELECT name FROM stadium WHERE capacity < (SELECT AVG(capacity) FROM stadium)


Question:
Show the names of editors that are on at least two journal committees.
Additional table information: table: journal_committee

Answer: SELECT T1.Name FROM editor AS T1 JOIN journal_committee AS T2 ON T1.Editor_ID = T2.Editor_ID GROUP BY T1.Name HAVING COUNT(*) >= 2


Question:
What are the first and last names for all customers?
Additional table information: table: driving_school

Answer: SELECT first_name, last_name FROM Customers


Question:
Show the member name and hometown who registered a branch in 2016.
Additional table information: table: shop_membership

Answer: SELECT T2.name, T2.hometown FROM membership_register_branch AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T1.register_year = 2016


Question:
How many clubs does 'Linda Smith' belong to?
Additional table information: table: club_1

Answer: SELECT COUNT(*) 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 = 'Linda' AND t3.lname = 'Smith'


Question:
Show the name of each party and the corresponding 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:
How many actors are there?
Additional table information: table: musical

Answer: SELECT COUNT(*) FROM actor


Question:
What are the names of all the Japanese constructors that have earned more than 5 points?
Additional table information: table: formula_1

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


Question:
What is the first and last name of all students who play 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:
How many classes are professor whose last name is Graztevski has?
Additional table information: table: college_1

Answer: SELECT COUNT(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'


Question:
Show the apartment type code that has the largest number of total rooms, together with the number of bathrooms and number of bedrooms.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, bathroom_count, bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY SUM(room_count) DESC LIMIT 1


Question:
List the id and type of each thing, and the details of the organization that owns it.
Additional table information: table: local_govt_and_lot

Answer: SELECT T1.thing_id, T1.type_of_Thing_Code, T2.organization_details FROM Things AS T1 JOIN Organizations AS T2 ON T1.organization_id = T2.organization_id


Question:
List the amount and donor name for the largest amount of donation.
Additional table information: table: school_finance

Answer: SELECT amount, donator_name FROM endowment ORDER BY amount DESC LIMIT 1


Question:
List the names of people that are not employed by any company
Additional table information: table: company_employee

Answer: SELECT Name FROM people WHERE NOT People_ID IN (SELECT People_ID FROM employment)


Question:
What are the first names for students who have an 'a' in their first name?
Additional table information: table: college_3

Answer: SELECT DISTINCT Fname FROM STUDENT WHERE Fname LIKE '%a%'


Question:
What are the names of all products that are not the most frequently-used maximum page size?
Additional table information: table: store_product

Answer: SELECT product FROM product WHERE product <> (SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY COUNT(*) DESC LIMIT 1)


Question:
What are the average and minimum weights for people of each sex?
Additional table information: table: candidate_poll

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


Question:
Which manufacturer has the most number of shops? List its name and year of opening.
Additional table information: table: manufacturer

Answer: SELECT open_year, name FROM manufacturer ORDER BY num_of_shops DESC LIMIT 1


Question:
Which vocal type has the band mate with first name 'Solveig' played the most?
Additional table information: table: music_2

Answer: SELECT TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE firstname = 'Solveig' GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many lesson does customer with first name Ray took?
Additional table information: table: driving_school

Answer: SELECT COUNT(*) FROM Lessons AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Ray'


Question:
Find the name and price of the product that has been ordered the greatest number of times.
Additional table information: table: customer_deliveries

Answer: SELECT t1.product_name, t1.product_price FROM products AS t1 JOIN regular_order_products AS t2 ON t1.product_id = t2.product_id GROUP BY t2.product_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the states with the most invoices?
Additional table information: table: store_1

Answer: SELECT billing_state, COUNT(*) FROM invoices WHERE billing_country = 'USA' GROUP BY billing_state ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the dates of enrollment and completion of the student with family name 'Zieme' and personal name 'Bernie'.
Additional table information: table: e_learning

Answer: SELECT T1.date_of_enrolment, T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.family_name = 'Zieme' AND T2.personal_name = 'Bernie'


Question:
Show the name and opening year for three churches that opened most recently.
Additional table information: table: wedding

Answer: SELECT name, open_date FROM church ORDER BY open_date DESC LIMIT 3


Question:
What is the complete description of the researcher role.
Additional table information: table: tracking_grants_for_research

Answer: SELECT role_description FROM Staff_Roles WHERE role_code = 'researcher'


Question:
Find the id of instructors who didn't teach any courses?
Additional table information: table: college_2

Answer: SELECT id FROM instructor EXCEPT SELECT id FROM teaches


Question:
What are the titles of papers published by 'Jeremy Gibbons'?
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 = 'Jeremy' AND t1.lname = 'Gibbons'


Question:
What are the names of all aircrafts that can cover more distances than average?
Additional table information: table: flight_1

Answer: SELECT name FROM Aircraft WHERE distance > (SELECT AVG(distance) FROM Aircraft)


Question:
What are the names of products with category 'Spices'?
Additional table information: table: products_gen_characteristics

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


Question:
For each constructor id, how many races are there?
Additional table information: table: formula_1

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


Question:
Who is the person whose age is below 30?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE age < 30


Question:
For each origin, how many flights came from there?
Additional table information: table: flight_1

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


Question:
What are the names for the 3 branches that have the most memberships?
Additional table information: table: shop_membership

Answer: SELECT name FROM branch ORDER BY membership_amount DESC LIMIT 3


Question:
List all player names who have an overall rating higher than the average.
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 WHERE T2.overall_rating > (SELECT AVG(overall_rating) FROM Player_Attributes)


Question:
Which fault log included the most number of faulty parts? List the fault log id, description and record time.
Additional table information: table: assets_maintenance

Answer: SELECT T1.fault_log_entry_id, T1.fault_description, T1.fault_log_entry_datetime FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which studios have an average gross of over 4500000?
Additional table information: table: film_rank

Answer: SELECT Studio FROM film GROUP BY Studio HAVING AVG(Gross_in_dollar) >= 4500000


Question:
What is the name of each dorm that has a TV Lounge but no study rooms?
Additional table information: table: dorm_1

Answer: 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' 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 = 'Study Room'


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

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


Question:
What is the type of the document named 'David CV'?
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents WHERE document_name = 'David CV'


Question:
Find the names of all races held in 2017.
Additional table information: table: formula_1

Answer: SELECT name FROM races WHERE YEAR = 2017


Question:
What are the the full names and ids for all customers, and how many accounts does each have?
Additional table information: table: customers_and_invoices

Answer: SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name, COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id


Question:
Which clubs have one or more members from the city with code 'BAL'? 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 = 'BAL'


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

Answer: SELECT name, openning_year, capacity FROM cinema


Question:
How many distinct types of accounts are there?
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT acc_type) FROM customer


Question:
Count the number of characteristics of the 'flax' product.
Additional table information: table: products_gen_characteristics

Answer: SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = 'flax'


Question:
For each type of store, how many of them are there?
Additional table information: table: store_product

Answer: SELECT TYPE, COUNT(*) FROM store GROUP BY TYPE


Question:
What is the description of role code ED?
Additional table information: table: cre_Doc_Control_Systems

Answer: SELECT role_description FROM ROLES WHERE role_code = 'ED'


Question:
What are ids of the faculty members who not only participate in an activity but also advise a student.
Additional table information: table: activity_1

Answer: SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student


Question:
What are the different film Directors?
Additional table information: table: film_rank

Answer: SELECT DISTINCT Director FROM film


Question:
Count the number of different software platforms.
Additional table information: table: device

Answer: SELECT COUNT(DISTINCT Software_Platform) FROM device


Question:
Return the apartment number with the largest number of bedrooms.
Additional table information: table: apartment_rentals

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


Question:
What are the first names and birthdates of the professors in charge of ACCT-211?
Additional table information: table: college_1

Answer: SELECT DISTINCT T1.EMP_FNAME, T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = 'ACCT-211'


Question:
How many students are advised by each rank of faculty? List the rank and the number of students.
Additional table information: table: activity_1

Answer: SELECT T1.rank, COUNT(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.rank


Question:
How many eliminations did each team have?
Additional table information: table: wrestler

Answer: SELECT Team, COUNT(*) FROM elimination GROUP BY Team


Question:
Show different teams in eliminations and the number of eliminations from each team.
Additional table information: table: wrestler

Answer: SELECT Team, COUNT(*) FROM elimination GROUP BY Team


Question:
What are department ids for departments with managers managing more than 3 employees?
Additional table information: table: hr_1

Answer: SELECT DISTINCT department_id FROM employees GROUP BY department_id, manager_id HAVING COUNT(employee_id) >= 4


Question:
What is the title of the course with Differential Geometry as a prerequisite?
Additional table information: table: college_2

Answer: SELECT title FROM course WHERE course_id IN (SELECT T1.course_id FROM prereq AS T1 JOIN course AS T2 ON T1.prereq_id = T2.course_id WHERE T2.title = 'Differential Geometry')


Question:
How many different instruments does the musician with the last name 'Heilo' use?
Additional table information: table: music_2

Answer: SELECT COUNT(DISTINCT instrument) FROM instruments AS T1 JOIN Band AS T2 ON T1.bandmateid = T2.id WHERE T2.lastname = 'Heilo'


Question:
List the names of shops that have no 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:
What are the valid from and valid to dates for the card with the number 4560596484842?
Additional table information: table: customers_card_transactions

Answer: SELECT date_valid_from, date_valid_to FROM Customers_cards WHERE card_number = '4560596484842'


Question:
Report the distinct president vote and the vice president vote.
Additional table information: table: voter_2

Answer: SELECT DISTINCT President_Vote, VICE_President_Vote FROM VOTING_RECORD


Question:
Which grade is studying in classroom 103?
Additional table information: table: student_1

Answer: SELECT DISTINCT grade FROM list WHERE classroom = 103


Question:
Find the number of courses provided in each semester and year.
Additional table information: table: college_2

Answer: SELECT COUNT(*), semester, YEAR FROM SECTION GROUP BY semester, YEAR


Question:
What document types have more than 2 corresponding documents?
Additional table information: table: document_management

Answer: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 2


Question:
Which company started the earliest the maintenance contract? Show the company name.
Additional table information: table: assets_maintenance

Answer: SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id ORDER BY T2.contract_start_date ASC NULLS FIRST LIMIT 1


Question:
What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?
Additional table information: table: loan_1

Answer: SELECT T1.cust_name, T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING SUM(T2.amount) > 5000


Question:
Give the color of the grape whose wine products have the highest average price?
Additional table information: table: wine_1

Answer: SELECT T1.Color FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape GROUP BY T2.Grape ORDER BY AVG(Price) DESC LIMIT 1


Question:
Which advisors are advising more than 2 students?
Additional table information: table: voter_2

Answer: SELECT Advisor FROM STUDENT GROUP BY Advisor HAVING COUNT(*) > 2


Question:
What is the date when the document 'Marry CV' was stored?
Additional table information: table: cre_Doc_Tracking_DB

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


Question:
what is the number of different channel owners?
Additional table information: table: program_share

Answer: SELECT COUNT(DISTINCT OWNER) FROM channel


Question:
What is the total checking balance in all accounts?
Additional table information: table: small_bank_1

Answer: SELECT SUM(balance) FROM checking


Question:
List the personal names and family names of all the students in alphabetical order of family name.
Additional table information: table: e_learning

Answer: SELECT personal_name, family_name FROM Students ORDER BY family_name NULLS FIRST


Question:
List all the login names and family names of course author and tutors.
Additional table information: table: e_learning

Answer: SELECT login_name, family_name FROM Course_Authors_and_Tutors


Question:
What are the last names of individuals who have been contact individuals for an organization?
Additional table information: table: e_government

Answer: SELECT DISTINCT t1.individual_last_name FROM individuals AS t1 JOIN organization_contact_individuals AS t2 ON t1.individual_id = t2.individual_id


Question:
What are the codes and names for all regions, sorted by codes?
Additional table information: table: storm_record

Answer: SELECT region_code, region_name FROM region ORDER BY region_code NULLS FIRST


Question:
Find the average rating star for each movie that received at least 2 ratings.
Additional table information: table: movie_1

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


Question:
What is the id of the reviewer whose name includes the word 'Mike'?
Additional table information: table: movie_1

Answer: SELECT rID FROM Reviewer WHERE name LIKE '%Mike%'


Question:
What are the dates that have the 5 highest cloud cover rates and what are the rates?
Additional table information: table: bike_1

Answer: SELECT date, cloud_cover FROM weather ORDER BY cloud_cover DESC LIMIT 5


Question:
Which district has the largest population?
Additional table information: table: store_product

Answer: SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1


Question:
Count the number of departments which offer courses.
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT dept_name) FROM course


Question:
How many regions do we have?
Additional table information: table: party_people

Answer: SELECT COUNT(*) FROM region


Question:
Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
Additional table information: table: dorm_1

Answer: SELECT T1.fname, T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE NOT T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')


Question:
Which order's shipment tracking number is '3452'? Give me the id of the order.
Additional table information: table: tracking_orders

Answer: SELECT order_id FROM shipments WHERE shipment_tracking_number = '3452'


Question:
Find the dates on which more than one revisions were made.
Additional table information: table: product_catalog

Answer: SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING COUNT(*) > 1


Question:
When did the first staff member start working?
Additional table information: table: tracking_grants_for_research

Answer: SELECT date_from FROM Project_Staff ORDER BY date_from ASC NULLS FIRST LIMIT 1


Question:
What are the employee ids of employees who report to Payam, and what are their salaries?
Additional table information: table: hr_1

Answer: SELECT employee_id, salary FROM employees WHERE manager_id = (SELECT employee_id FROM employees WHERE first_name = 'Payam')


Question:
How many credits does course CIS-220 have, and what its description?
Additional table information: table: college_1

Answer: SELECT crs_credit, crs_description FROM course WHERE crs_code = 'CIS-220'


Question:
What is the average room count of the apartments whose booking status code is 'Provisional'?
Additional table information: table: apartment_rentals

Answer: SELECT AVG(room_count) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Provisional'


Question:
What are distinct locations where tracks are located?
Additional table information: table: race_track

Answer: SELECT DISTINCT LOCATION FROM track


Question:
How many kinds of roles are there for the staff?
Additional table information: table: tracking_grants_for_research

Answer: SELECT COUNT(DISTINCT role_code) FROM Project_Staff


Question:
Who is the youngest male?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE gender = 'male' AND age = (SELECT MIN(age) FROM person WHERE gender = 'male')


Question:
What are the forename and surname of the driver who has the smallest laptime?
Additional table information: table: formula_1

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


Question:
For each classroom with at least 2 classes, how many classes are offered?
Additional table information: table: college_1

Answer: SELECT COUNT(*), class_room FROM CLASS GROUP BY class_room HAVING COUNT(*) >= 2


Question:
Please show the different statuses, ordered by the number of cities that have each.
Additional table information: table: farm

Answer: SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC NULLS FIRST


Question:
Show the advisors of the students whose city of residence has city code 'BAL'.
Additional table information: table: voter_2

Answer: SELECT Advisor FROM STUDENT WHERE city_code = 'BAL'


Question:
How many document types are there?
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT COUNT(*) FROM Ref_document_types


Question:
Count how many appointments have been made in total.
Additional table information: table: hospital_1

Answer: SELECT COUNT(*) FROM appointment


Question:
What are the names of all the teams in the basketball competition, sorted by all home scores in descending order?
Additional table information: table: university_basketball

Answer: SELECT team_name FROM basketball_match ORDER BY All_Home DESC


Question:
List the name and country of origin for all singers who have produced songs with rating above 9.
Additional table information: table: music_1

Answer: SELECT DISTINCT T1.artist_name, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.rating > 9


Question:
What are the ids and details for all organizations that have grants of more than 6000 dollars?
Additional table information: table: tracking_grants_for_research

Answer: SELECT T2.organisation_id, T2.organisation_details FROM Grants AS T1 JOIN Organisations AS T2 ON T1.organisation_id = T2.organisation_id GROUP BY T2.organisation_id HAVING SUM(T1.grant_amount) > 6000


Question:
Find the names of the companies whose headquarters are not located in 'USA'.
Additional table information: table: company_office

Answer: SELECT name FROM Companies WHERE Headquarters <> 'USA'


Question:
What is the name of the oldest student?
Additional table information: table: network_2

Answer: SELECT name FROM Person WHERE job = 'student' AND age = (SELECT MAX(age) FROM person WHERE job = 'student')


Question:
What are the names of perpetrators whose country is not 'China'?
Additional table information: table: perpetrator

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


Question:
What are the total and average enrollment of all schools?
Additional table information: table: school_finance

Answer: SELECT SUM(enrollment), AVG(enrollment) FROM school


Question:
What is the description and code of the type of service that is performed the most often?
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT T1.Service_Type_Description, T1.Service_Type_Code FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code GROUP BY T1.Service_Type_Code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the full names of all students
Additional table information: table: allergy_1

Answer: SELECT Fname, Lname FROM Student


Question:
Show the location with most number of train stations.
Additional table information: table: train_station

Answer: SELECT LOCATION FROM station GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the names and years released for the movies with the top 3 highest ratings?
Additional table information: table: movie_1

Answer: SELECT T2.title, T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID ORDER BY T1.stars DESC LIMIT 3


Question:
How many courses that do not have prerequisite?
Additional table information: table: college_2

Answer: SELECT COUNT(*) FROM course WHERE NOT course_id IN (SELECT course_id FROM prereq)


Question:
List all ship names in the order of built year and class.
Additional table information: table: ship_1

Answer: SELECT name FROM ship ORDER BY built_year NULLS FIRST, CLASS NULLS FIRST


Question:
Show the number of customer cards.
Additional table information: table: customers_card_transactions

Answer: SELECT COUNT(*) FROM Customers_cards


Question:
What is all the information about the Marketing department?
Additional table information: table: hr_1

Answer: SELECT * FROM departments WHERE department_name = 'Marketing'


Question:
Show different builders of railways, along with the corresponding number of railways using each builder.
Additional table information: table: railway

Answer: SELECT Builder, COUNT(*) FROM railway GROUP BY Builder


Question:
What is the label that has the most albums?
Additional table information: table: music_2

Answer: SELECT label FROM albums GROUP BY label ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the writers of the books in ascending alphabetical order.
Additional table information: table: book_2

Answer: SELECT Writer FROM book ORDER BY Writer ASC NULLS FIRST


Question:
Show the prices of publications whose publisher is either 'Person' or 'Wiley'
Additional table information: table: book_2

Answer: SELECT Price FROM publication WHERE Publisher = 'Person' OR Publisher = 'Wiley'


Question:
Which attraction type does the most tourist attractions belong to? Tell me its  attraction type description and code.
Additional table information: table: cre_Theme_park

Answer: SELECT T1.Attraction_Type_Description, T2.Attraction_Type_Code FROM Ref_Attraction_Types AS T1 JOIN Tourist_Attractions AS T2 ON T1.Attraction_Type_Code = T2.Attraction_Type_Code GROUP BY T2.Attraction_Type_Code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the average room count of the apartments that have booking status code 'Provisional'.
Additional table information: table: apartment_rentals

Answer: SELECT AVG(room_count) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Provisional'


Question:
Please show the industries of companies in descending order of the number of companies.
Additional table information: table: company_office

Answer: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC


Question:
Show all team names.
Additional table information: table: match_season

Answer: SELECT Name FROM Team


Question:
What is the name and country of origin of the artist who released a song that has 'love' in its title?
Additional table information: table: music_1

Answer: SELECT T1.artist_name, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.song_name LIKE '%love%'


Question:
Find the max and min grade point for all letter grade.
Additional table information: table: college_3

Answer: SELECT MAX(gradepoint), MIN(gradepoint) FROM GRADECONVERSION


Question:
What is the list of distinct product names sorted by product id?
Additional table information: table: tracking_software_problems

Answer: SELECT DISTINCT product_name FROM product ORDER BY product_id NULLS FIRST


Question:
What are the names of device shops, and what are the carriers that they carry devices in stock for?
Additional table information: table: device

Answer: SELECT T3.Shop_Name, T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID = T2.Device_ID JOIN shop AS T3 ON T1.Shop_ID = T3.Shop_ID


Question:
What are the first names of all students who took ACCT-211 and received a C?
Additional table information: table: college_1

Answer: SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211' AND T2.enroll_grade = 'C'


Question:
What are the unique block codes that have available rooms?
Additional table information: table: hospital_1

Answer: SELECT DISTINCT blockcode FROM room WHERE unavailable = 0


Question:
What is the checking balance of the account whose owner’s name contains the substring ‘ee’?
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 LIKE '%ee%'


Question:
which shop has happy hour most frequently? List its id and number of happy hours.
Additional table information: table: coffee_shop

Answer: SELECT shop_id, COUNT(*) FROM happy_hour GROUP BY shop_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many different locations does the school with code BUS has?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'


Question:
Show first name and id for all customers with at least 2 accounts.
Additional table information: table: customers_and_invoices

Answer: SELECT T2.customer_first_name, T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2


Question:
How many courses are there in total?
Additional table information: table: e_learning

Answer: SELECT COUNT(*) FROM COURSES


Question:
Please show the countries and the number of climbers from each country.
Additional table information: table: climbing

Answer: SELECT Country, COUNT(*) FROM climber GROUP BY Country


Question:
Find the id of the item whose title is 'orange'.
Additional table information: table: epinions_1

Answer: SELECT i_id FROM item WHERE title = 'orange'


Question:
What is the count of aircrafts that have a distance between 1000 and 5000?
Additional table information: table: flight_1

Answer: SELECT COUNT(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000


Question:
What are the different location codes for documents?
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT DISTINCT location_code FROM Document_locations


Question:
Tell me the name of the staff in charge of the attraction called 'US museum'.
Additional table information: table: cre_Theme_park

Answer: SELECT T1.Name FROM STAFF AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T2.Name = 'US museum'


Question:
Which type of policy is most frequently used? Give me the policy type code.
Additional table information: table: insurance_and_eClaims

Answer: SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many times in total did the team Boston Red Stockings participate in postseason games?
Additional table information: table: baseball_1

Answer: SELECT COUNT(*) FROM (SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' UNION SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings')


Question:
What is the author of the submission with the highest score?
Additional table information: table: workshop_paper

Answer: SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1


Question:
Find the claim that has the largest total settlement amount. Return the effective date of the claim.
Additional table information: table: insurance_fnol

Answer: SELECT t1.Effective_Date FROM claims AS t1 JOIN settlements AS t2 ON t1.claim_id = t2.claim_id GROUP BY t1.claim_id ORDER BY SUM(t2.settlement_amount) DESC LIMIT 1


Question:
What are the names of the songs whose rating is below the rating of all songs in English?
Additional table information: table: music_1

Answer: SELECT song_name FROM song WHERE rating < (SELECT MIN(rating) FROM song WHERE languages = 'english')


Question:
Find the code of city where most of students are living in.
Additional table information: table: dorm_1

Answer: SELECT city_code FROM student GROUP BY city_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the ids of all distinct orders ordered by placed date.
Additional table information: table: tracking_orders

Answer: SELECT DISTINCT order_id FROM orders ORDER BY date_order_placed NULLS FIRST


Question:
Return the name of the characteristic that is most common across all products.
Additional table information: table: products_gen_characteristics

Answer: SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id GROUP BY t3.characteristic_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the names of all the clubs ordered in descending alphabetical order?
Additional table information: table: sports_competition

Answer: SELECT name FROM club ORDER BY name DESC


Question:
What is the last name of the artist who sang the most 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:
Which start station had the most trips starting from August? Give me the name and id of the station.
Additional table information: table: bike_1

Answer: SELECT start_station_name, start_station_id FROM trip WHERE start_date LIKE '8/%' GROUP BY start_station_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
Return the sum of all payment amounts.
Additional table information: table: sakila_1

Answer: SELECT SUM(amount) FROM payment


Question:
What are the ids of the students who registered course statistics by order of registration date?
Additional table information: table: student_assessment

Answer: SELECT T2.student_id FROM courses AS T1 JOIN student_course_registrations AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = 'statistics' ORDER BY T2.registration_date NULLS FIRST


Question:
What is the type with the fewest games?
Additional table information: table: game_1

Answer: SELECT gtype FROM Video_games GROUP BY gtype ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
How many distinct teams are involved in match seasons?
Additional table information: table: match_season

Answer: SELECT COUNT(DISTINCT Team) FROM match_season


Question:
Show all video game types.
Additional table information: table: game_1

Answer: SELECT DISTINCT gtype FROM Video_games


Question:
List the names, color descriptions and product descriptions of products with category 'Herbs'.
Additional table information: table: products_gen_characteristics

Answer: SELECT T1.product_name, T2.color_description, T1.product_description FROM products AS T1 JOIN Ref_colors AS T2 ON T1.color_code = T2.color_code WHERE product_category_code = 'Herbs'


Question:
What are the wines that have prices higher than 50 and made of Red color grapes?
Additional table information: table: wine_1

Answer: SELECT T2.Name FROM Grapes AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape WHERE T1.Color = 'Red' AND T2.price > 50


Question:
Find the name of instructor who is the advisor of the student who has the highest 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:
Find the name and budget of departments whose budgets are more than the average budget.
Additional table information: table: college_2

Answer: SELECT dept_name, budget FROM department WHERE budget > (SELECT AVG(budget) FROM department)


Question:
For each country, what is the average elevation of that country's airports?
Additional table information: table: flight_4

Answer: SELECT AVG(elevation), country FROM airports GROUP BY country


Question:
Which catalog publisher has published the most catalogs?
Additional table information: table: product_catalog

Answer: SELECT catalog_publisher FROM catalogs GROUP BY catalog_publisher ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the names of entrepreneurs and their corresponding investors, ordered descending by the amount of money requested?
Additional table information: table: entrepreneur

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


Question:
What are the name and id of the three highest priced rooms?
Additional table information: table: inn_1

Answer: SELECT RoomId, roomName FROM Rooms ORDER BY basePrice DESC LIMIT 3


Question:
What is average number of students enrolled in Florida colleges?
Additional table information: table: soccer_2

Answer: SELECT AVG(enr) FROM College WHERE state = 'FL'


Question:
Find the first name and last name for the 'CTO' of the club 'Hopkins Student Enterprises'?
Additional table information: table: club_1

Answer: SELECT t3.fname, 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 = 'Hopkins Student Enterprises' AND t2.position = 'CTO'


Question:
Show all company names with a movie directed in year 1999.
Additional table information: table: culture_company

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


Question:
What details do we have on the students who registered for courses most recently?
Additional table information: table: student_assessment

Answer: SELECT T2.student_details FROM student_course_registrations AS T1 JOIN students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.registration_date DESC LIMIT 1


Question:
How many different statuses do cities have?
Additional table information: table: farm

Answer: SELECT COUNT(DISTINCT Status) FROM city


Question:
Count the number of rooms that are not in the Lamberton building.
Additional table information: table: college_2

Answer: SELECT COUNT(*) FROM classroom WHERE building <> 'Lamberton'


Question:
What is the name of the airport with the most number of routes that start in China?
Additional table information: table: flight_4

Answer: SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the description of transaction type with code 'PUR'.
Additional table information: table: tracking_share_transactions

Answer: SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = 'PUR'


Question:
How many characteristics are there?
Additional table information: table: products_gen_characteristics

Answer: SELECT COUNT(*) FROM CHARACTERISTICS


Question:
List all church names in descending order of opening date.
Additional table information: table: wedding

Answer: SELECT name FROM church ORDER BY open_date DESC


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

Answer: SELECT campus FROM campuses WHERE LOCATION = 'Northridge' AND county = 'Los Angeles' UNION SELECT campus FROM campuses WHERE LOCATION = 'San Francisco' AND county = 'San Francisco'


Question:
What are the names of wines whose production year are before the year of all wines by Brander winery?
Additional table information: table: wine_1

Answer: SELECT Name FROM WINE WHERE YEAR < (SELECT MIN(YEAR) FROM WINE WHERE Winery = 'Brander')


Question:
What is the duration of the oldest actor?
Additional table information: table: musical

Answer: SELECT Duration FROM actor ORDER BY Age DESC LIMIT 1


Question:
What is the name of the event that happened in the most recent year?
Additional table information: table: swimming

Answer: SELECT name FROM event ORDER BY YEAR DESC LIMIT 1


Question:
What is the average rating of songs produced by female artists?
Additional table information: table: music_1

Answer: SELECT AVG(T2.rating) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T1.gender = 'Female'


Question:
What is employee Nancy Edwards's phone number?
Additional table information: table: store_1

Answer: SELECT phone FROM employees WHERE first_name = 'Nancy' AND last_name = 'Edwards'


Question:
What is the average fee for a CSU campus in the year of 1996?
Additional table information: table: csu_1

Answer: SELECT AVG(campusfee) FROM csu_fees WHERE YEAR = 1996


Question:
What are the countries that contain 3 or more cities?
Additional table information: table: sakila_1

Answer: SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id GROUP BY T2.country_id HAVING COUNT(*) >= 3


Question:
When did customer with first name as Carole and last name as Bernhard became a customer?
Additional table information: table: driving_school

Answer: SELECT date_became_customer FROM Customers WHERE first_name = 'Carole' AND last_name = 'Bernhard'


Question:
Find the description of the claim status 'Open'.
Additional table information: table: insurance_and_eClaims

Answer: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'Open'


Question:
Return the name of the team and the acc during the regular season for the school that was founded the earliest.
Additional table information: table: university_basketball

Answer: SELECT t2.team_name, t2.ACC_Regular_Season FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id ORDER BY t1.founded NULLS FIRST LIMIT 1


Question:
What is the average bike availablility for stations not in Palo Alto?
Additional table information: table: bike_1

Answer: SELECT AVG(bikes_available) FROM status WHERE NOT station_id IN (SELECT id FROM station WHERE city = 'Palo Alto')


Question:
How many tracks does each genre have and what are the names of the top 5?
Additional table information: table: store_1

Answer: SELECT T1.name, COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 5


Question:
What are the main industries of the companies without gas stations and what are the companies?
Additional table information: table: gas_company

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


Question:
List the names of journalists in ascending order of years working.
Additional table information: table: news_report

Answer: SELECT Name FROM journalist ORDER BY Years_working ASC NULLS FIRST


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

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


Question:
List the name of all the distinct customers who have orders with status 'Packing'.
Additional table information: table: tracking_orders

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


Question:
What are the names of parties with at least 2 events?
Additional table information: table: party_people

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


Question:
What is the name of department where has the smallest number of professors?
Additional table information: table: college_1

Answer: SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
Which parties have more than 20 hosts? Give me the host names for these parties.
Additional table information: table: party_host

Answer: SELECT T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T3.Number_of_hosts > 20


Question:
How many pilots are there?
Additional table information: table: pilot_record

Answer: SELECT COUNT(*) FROM pilot


Question:
What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?
Additional table information: table: formula_1

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


Question:
Find the name of organizations whose names contain 'Party'.
Additional table information: table: e_government

Answer: SELECT organization_name FROM organizations WHERE organization_name LIKE '%Party%'


Question:
What are the names and prices of products that cost at least 180, sorted by price decreasing and name ascending?
Additional table information: table: manufactory_1

Answer: SELECT name, price FROM products WHERE price >= 180 ORDER BY price DESC, name ASC NULLS FIRST


Question:
What are the personal names and family names of the students? Sort the result in alphabetical order of the family name.
Additional table information: table: e_learning

Answer: SELECT personal_name, family_name FROM Students ORDER BY family_name NULLS FIRST


Question:
Find the name of the dorm with the largest capacity.
Additional table information: table: dorm_1

Answer: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1


Question:
What are the different names of mountains ascended by climbers from the country of West Germany?
Additional table information: table: climbing

Answer: SELECT DISTINCT T2.Name FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID = T2.Mountain_ID WHERE T1.Country = 'West Germany'


Question:
Find the names of the tourist attractions that is either accessible by bus or at address 254 Ottilie Junction.
Additional table information: table: cre_Theme_park

Answer: SELECT T2.Name FROM Locations AS T1 JOIN Tourist_Attractions AS T2 ON T1.Location_ID = T2.Location_ID WHERE T1.Address = '254 Ottilie Junction' OR T2.How_to_Get_There = 'bus'


Question:
What are the ids and names of the medicine that can interact with two or more enzymes?
Additional table information: table: medicine_enzyme_interaction

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


Question:
What is the average rating star for each reviewer?
Additional table information: table: movie_1

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


Question:
Count the number of customers recorded.
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT COUNT(*) FROM CUSTOMERS


Question:
Find the address line 1 and 2 of the customer with email 'vbogisich@example.org'.
Additional table information: table: customer_complaints

Answer: SELECT address_line_1, address_line_2 FROM customers WHERE email_address = 'vbogisich@example.org'


Question:
What is the total and maximum duration of trips with bike id 636?
Additional table information: table: bike_1

Answer: SELECT SUM(duration), MAX(duration) FROM trip WHERE bike_id = 636


Question:
How many routes go from the United States to Canada?
Additional table information: table: flight_4

Answer: SELECT COUNT(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States')


Question:
How many faculty do we have?
Additional table information: table: activity_1

Answer: SELECT COUNT(*) FROM Faculty


Question:
What is the city_code of the city that the most students live in?
Additional table information: table: voter_2

Answer: SELECT city_code FROM STUDENT GROUP BY city_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the distinct payment method codes with the number of orders made
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT payment_method_code, COUNT(*) FROM INVOICES GROUP BY payment_method_code


Question:
What is the first name of all employees who do not give any lessons?
Additional table information: table: driving_school

Answer: SELECT first_name FROM Staff EXCEPT SELECT T2.first_name FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id


Question:
How many distinct delegates are from counties with population larger than 50000?
Additional table information: table: election

Answer: SELECT COUNT(DISTINCT T2.Delegate) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population > 50000


Question:
List the names of phones that are not on any market.
Additional table information: table: phone_market

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


Question:
How many railways are there?
Additional table information: table: railway

Answer: SELECT COUNT(*) FROM railway


Question:
How many different roles are there on the project staff?
Additional table information: table: tracking_grants_for_research

Answer: SELECT COUNT(DISTINCT role_code) FROM Project_Staff


Question:
Show total points of all players.
Additional table information: table: sports_competition

Answer: SELECT SUM(Points) FROM player


Question:
What are the types of vocals used in the song 'Le Pop'?
Additional table information: table: music_2

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


Question:
What are the email addresses of the drama workshop groups with address 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:
What are the department ids, full names, and salaries for employees who make the most in their departments?
Additional table information: table: hr_1

Answer: SELECT first_name, last_name, salary, department_id, MAX(salary) FROM employees GROUP BY department_id


Question:
List the names of all distinct medications, ordered in an alphabetical order.
Additional table information: table: hospital_1

Answer: SELECT DISTINCT name FROM medication ORDER BY name NULLS FIRST


Question:
Find the name of tracks which are in both Movies and music playlists.
Additional table information: table: store_1

Answer: SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' INTERSECT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music'


Question:
List the names of phones in ascending order of price.
Additional table information: table: phone_market

Answer: SELECT Name FROM phone ORDER BY Price ASC NULLS FIRST


Question:
Find the number of universities that have over a 20000 enrollment size for each affiliation type.
Additional table information: table: university_basketball

Answer: SELECT COUNT(*), affiliation FROM university WHERE enrollment > 20000 GROUP BY affiliation


Question:
Find the names of the workshop groups where services with product name 'film' are performed.
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT T1.Store_Phone, T1.Store_Email_Address FROM Drama_Workshop_Groups AS T1 JOIN Services AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID WHERE T2.Product_Name = 'film'


Question:
Show all the ranks and the number of male and female faculty for each rank.
Additional table information: table: activity_1

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


Question:
Find courses that ran in Fall 2009 or in Spring 2010.
Additional table information: table: college_2

Answer: SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 UNION SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010


Question:
Return the official native languages of countries who have players from Maryland or Duke colleges.
Additional table information: table: match_season

Answer: SELECT T1.Official_native_language FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.College = 'Maryland' OR T2.College = 'Duke'


Question:
How many classrooms are not in Lamberton?
Additional table information: table: college_2

Answer: SELECT COUNT(*) FROM classroom WHERE building <> 'Lamberton'


Question:
Show the title and publication dates of books.
Additional table information: table: book_2

Answer: SELECT T1.Title, T2.Publication_Date FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID


Question:
Find the department with the most employees.
Additional table information: table: hospital_1

Answer: SELECT name FROM department GROUP BY departmentID ORDER BY COUNT(departmentID) DESC LIMIT 1


Question:
what are name and phone number of patients who had more than one appointment?
Additional table information: table: hospital_1

Answer: SELECT name, phone FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn GROUP BY T1.patient HAVING COUNT(*) > 1


Question:
Find the name and id of the item with the highest average rating.
Additional table information: table: epinions_1

Answer: SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rating) DESC LIMIT 1


Question:
Return the date of birth for all the guests with gender code 'Male'.
Additional table information: table: apartment_rentals

Answer: SELECT date_of_birth FROM Guests WHERE gender_code = 'Male'


Question:
Show all the activity names and the number of faculty involved in each activity.
Additional table information: table: activity_1

Answer: SELECT T1.activity_name, COUNT(*) FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID = T2.actID GROUP BY T1.actID


Question:
Show the most common position of players in match seasons.
Additional table information: table: match_season

Answer: SELECT POSITION FROM match_season GROUP BY POSITION ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the name of the department that has the largest number of students enrolled?
Additional table information: table: college_1

Answer: SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the id and name of the employee with maximum salary.
Additional table information: table: flight_1

Answer: SELECT eid, name FROM Employee ORDER BY salary DESC LIMIT 1


Question:
Find the average ram mib size of the chip models that are never used by any phone.
Additional table information: table: phone_1

Answer: SELECT AVG(RAM_MiB) FROM chip_model WHERE NOT model_name IN (SELECT chip_model FROM phone)


Question:
How many students have advisors?
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT s_id) FROM advisor


Question:
Find the number of team franchises that are active (have 'Y' as 'active' information).
Additional table information: table: baseball_1

Answer: SELECT COUNT(*) FROM team_franchise WHERE active = 'Y'


Question:
What are the names of all clubs?
Additional table information: table: club_1

Answer: SELECT clubname FROM club


Question:
Find the first name and gpa of the students whose gpa is lower than the average gpa of all students.
Additional table information: table: college_1

Answer: SELECT stu_fname, stu_gpa FROM student WHERE stu_gpa < (SELECT AVG(stu_gpa) FROM student)


Question:
What are the types of competition and number of competitions for that type?
Additional table information: table: sports_competition

Answer: SELECT Competition_type, COUNT(*) FROM competition GROUP BY Competition_type


Question:
What are the unique ids of those departments where any manager is managing 4 or more employees.
Additional table information: table: hr_1

Answer: SELECT DISTINCT department_id FROM employees GROUP BY department_id, manager_id HAVING COUNT(employee_id) >= 4


Question:
Find the names of customers who have used either the service 'Close a policy' or the service 'Upgrade a policy'.
Additional table information: table: insurance_fnol

Answer: SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = 'Close a policy' OR t3.service_name = 'Upgrade a policy'


Question:
What is the zip code of the customer Carole Bernhard?
Additional table information: table: driving_school

Answer: SELECT T2.zip_postcode FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T1.first_name = 'Carole' AND T1.last_name = 'Bernhard'


Question:
When did the staff member Janessa Sawayn leave the company?
Additional table information: table: driving_school

Answer: SELECT date_left_staff FROM Staff WHERE first_name = 'Janessa' AND last_name = 'Sawayn'


Question:
Show all publishers and the number of books for each publisher.
Additional table information: table: culture_company

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


Question:
What are the first and last names of all customers who lived in Lockmanfurt?
Additional table information: table: driving_school

Answer: SELECT T1.first_name, T1.last_name FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T2.city = 'Lockmanfurt'


Question:
Show all distinct cities in the address record.
Additional table information: table: customers_and_products_contacts

Answer: SELECT DISTINCT city FROM addresses


Question:
Find 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:
How many times the number of adults and kids staying in a room reached the maximum capacity of the room?
Additional table information: table: inn_1

Answer: SELECT COUNT(*) FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T2.maxOccupancy = T1.Adults + T1.Kids


Question:
Return the distinct customer details.
Additional table information: table: insurance_policies

Answer: SELECT DISTINCT customer_details FROM Customers


Question:
How many party events do we have?
Additional table information: table: party_people

Answer: SELECT COUNT(*) FROM party_events


Question:
What are the ids, date opened, name, and other details for all accounts?
Additional table information: table: customers_and_invoices

Answer: SELECT account_id, date_account_opened, account_name, other_account_details FROM Accounts


Question:
Which types of policy are chosen by more than 2 customers? Give me the policy type codes.
Additional table information: table: insurance_and_eClaims

Answer: SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING COUNT(*) > 2


Question:
List the name of ships in ascending order of tonnage.
Additional table information: table: ship_mission

Answer: SELECT Name FROM ship ORDER BY Tonnage ASC NULLS FIRST


Question:
How many courses are offered?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT crs_code) FROM CLASS


Question:
What are the names of all airports whose elevation is between -50 and 50?
Additional table information: table: flight_4

Answer: SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50


Question:
which pilot is in charge of the most number of flights?
Additional table information: table: flight_company

Answer: SELECT pilot FROM flight GROUP BY pilot ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the most common interaction type between enzymes and medicine? And how many are there?
Additional table information: table: medicine_enzyme_interaction

Answer: SELECT interaction_type, COUNT(*) FROM medicine_enzyme_interaction GROUP BY interaction_type ORDER BY COUNT(*) DESC LIMIT 1


Question:
Give the city that the student whose family name is Kim lives in.
Additional table information: table: allergy_1

Answer: SELECT city_code FROM Student WHERE LName = 'Kim'


Question:
Find the name of physicians who are in charge of more than one patient.
Additional table information: table: hospital_1

Answer: SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING COUNT(*) > 1


Question:
What are the names of the tourist attractions that can be accessed by bus?
Additional table information: table: cre_Theme_park

Answer: SELECT Name FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = 'bus'


Question:
Show the name and date for each race and its track name.
Additional table information: table: race_track

Answer: SELECT T1.name, T1.date, T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id


Question:
How many distinct names are associated with all the photos?
Additional table information: table: cre_Theme_park

Answer: SELECT COUNT(DISTINCT Name) FROM PHOTOS


Question:
Which language does the film AIRPORT POLLOCK use? List the language name.
Additional table information: table: sakila_1

Answer: SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK'


Question:
Which country has both stadiums with capacity greater than 60000 and stadiums with capacity less than 50000?
Additional table information: table: swimming

Answer: SELECT country FROM stadium WHERE capacity > 60000 INTERSECT SELECT country FROM stadium WHERE capacity < 50000


Question:
Return the average transaction amount, as well as the total amount of all transactions.
Additional table information: table: customers_card_transactions

Answer: SELECT AVG(transaction_amount), SUM(transaction_amount) FROM Financial_transactions


Question:
What are the resident details containing the substring 'Miss'?
Additional table information: table: local_govt_and_lot

Answer: SELECT other_details FROM Residents WHERE other_details LIKE '%Miss%'


Question:
What are the ids of the students who either registered or attended a course?
Additional table information: table: student_assessment

Answer: SELECT student_id FROM student_course_registrations UNION SELECT student_id FROM student_course_attendance


Question:
How many classes are held in each department?
Additional table information: table: college_1

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


Question:
How many courses are provided in each semester and year?
Additional table information: table: college_2

Answer: SELECT COUNT(*), semester, YEAR FROM SECTION GROUP BY semester, YEAR


Question:
What were all the salary values of players in 2010 and 2001?
Additional table information: table: baseball_1

Answer: SELECT salary FROM salary WHERE YEAR = 2010 UNION SELECT salary FROM salary WHERE YEAR = 2001


Question:
What is the location name of the document 'Robin CV'?
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT T3.location_name FROM All_documents AS T1 JOIN Document_locations AS T2 ON T1.document_id = T2.document_id JOIN Ref_locations AS T3 ON T2.location_code = T3.location_code WHERE T1.document_name = 'Robin CV'


Question:
What is the country in which the customer Carole Bernhard lived?
Additional table information: table: driving_school

Answer: SELECT T2.country FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T1.first_name = 'Carole' AND T1.last_name = 'Bernhard'


Question:
Where is the club 'Pen and Paper Gaming' located?
Additional table information: table: club_1

Answer: SELECT clublocation FROM club WHERE clubname = 'Pen and Paper Gaming'


Question:
Return the names of teams that have no match season record.
Additional table information: table: match_season

Answer: SELECT Name FROM team WHERE NOT Team_id IN (SELECT Team FROM match_season)


Question:
Show the season, the player, and the name of the country that player belongs to.
Additional table information: table: match_season

Answer: SELECT T2.Season, T2.Player, T1.Country_name FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country


Question:
List the project details of the projects launched by the organisation
Additional table information: table: tracking_grants_for_research

Answer: SELECT project_details FROM Projects WHERE organisation_id IN (SELECT organisation_id FROM Projects GROUP BY organisation_id ORDER BY COUNT(*) DESC LIMIT 1)


Question:
List the grape, winery and year of the wines whose price is bigger than 100 ordered by year.
Additional table information: table: wine_1

Answer: SELECT Grape, Winery, YEAR FROM WINE WHERE Price > 100 ORDER BY YEAR NULLS FIRST


Question:
Give me a list of cities whose temperature in March is lower than that in July or higher than that in Oct?
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 WHERE T2.Mar < T2.Jul OR T2.Mar > T2.Oct


Question:
What are the companies and investors that correspond to each entrepreneur?
Additional table information: table: entrepreneur

Answer: SELECT Company, Investor FROM entrepreneur


Question:
What is the full name of the instructor who has a course named COMPUTER LITERACY?
Additional table information: table: college_3

Answer: SELECT T2.Fname, T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor = T2.FacID WHERE T1.CName = 'COMPUTER LITERACY'


Question:
What are the origins of all flights that are headed to Honolulu?
Additional table information: table: flight_1

Answer: SELECT origin FROM Flight WHERE destination = 'Honolulu'


Question:
How many artists are there?
Additional table information: table: music_4

Answer: SELECT COUNT(*) FROM artist


Question:
List the names of the top 5 oldest people.
Additional table information: table: gymnast

Answer: SELECT Name FROM People ORDER BY Age DESC LIMIT 5


Question:
Which orders have shipment after 2000-01-01? Give me the order ids.
Additional table information: table: tracking_orders

Answer: SELECT order_id FROM shipments WHERE shipment_date > '2000-01-01'


Question:
In which distinct years was the governor 'Eliot Spitzer'?
Additional table information: table: election

Answer: SELECT DISTINCT YEAR FROM party WHERE Governor = 'Eliot Spitzer'


Question:
Find the number of classes offered for all class rooms that held at least 2 classes.
Additional table information: table: college_1

Answer: SELECT COUNT(*), class_room FROM CLASS GROUP BY class_room HAVING COUNT(*) >= 2


Question:
Find the number of students in total.
Additional table information: table: student_1

Answer: SELECT COUNT(*) FROM list


Question:
What is the tax source system code related to the benefits and overpayments? List the code and the benifit id, order by benifit id.
Additional table information: table: local_govt_mdm

Answer: SELECT T1.source_system_code, T2.council_tax_id FROM CMI_Cross_References AS T1 JOIN Benefits_Overpayments AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id ORDER BY T2.council_tax_id NULLS FIRST


Question:
Show the minimum, maximum, and average age for all people.
Additional table information: table: wedding

Answer: SELECT MIN(age), MAX(age), AVG(age) FROM people


Question:
How many gas companies are there?
Additional table information: table: gas_company

Answer: SELECT COUNT(*) FROM company


Question:
What is the number of employees that have a salary between 100000 and 200000?
Additional table information: table: flight_1

Answer: SELECT COUNT(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000


Question:
Find names of instructors with salary greater than that of some (at least one) instructor in the Biology department.
Additional table information: table: college_2

Answer: SELECT name FROM instructor WHERE salary > (SELECT MIN(salary) FROM instructor WHERE dept_name = 'Biology')


Question:
Show the names of sponsors of players whose residence is either 'Brandon' or 'Birtle'.
Additional table information: table: riding_club

Answer: SELECT Sponsor_name FROM player WHERE Residence = 'Brandon' OR Residence = 'Birtle'


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

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


Question:
Find the cities which were once a host city after 2010?
Additional table information: table: city_record

Answer: SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T2.year > 2010


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

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


Question:
List all the customers in increasing order of IDs.
Additional table information: table: insurance_fnol

Answer: SELECT customer_id, customer_name FROM customers ORDER BY customer_id ASC NULLS FIRST


Question:
How much did the the player with first name Len and last name Barker earn between 1985 to 1990 in total?
Additional table information: table: baseball_1

Answer: SELECT SUM(T1.salary) FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id WHERE T2.name_first = 'Len' AND T2.name_last = 'Barker' AND T1.year BETWEEN 1985 AND 1990


Question:
Return the names of musicals who have the nominee Bob Fosse.
Additional table information: table: musical

Answer: SELECT Name FROM musical WHERE Nominee = 'Bob Fosse'


Question:
What are the names, checking balances, and savings balances for all customers?
Additional table information: table: small_bank_1

Answer: SELECT T2.balance, T3.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid


Question:
How many distinct FDA approval statuses are there for the medicines?
Additional table information: table: medicine_enzyme_interaction

Answer: SELECT COUNT(DISTINCT FDA_approved) FROM medicine


Question:
What is the role code with the largest number of employees?
Additional table information: table: cre_Doc_Tracking_DB

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


Question:
How many orders have detail 'Second time'?
Additional table information: table: customers_and_addresses

Answer: SELECT COUNT(*) FROM customer_orders WHERE order_details = 'Second time'


Question:
What is minimum age for different job title?
Additional table information: table: network_2

Answer: SELECT MIN(age), job FROM Person GROUP BY job


Question:
What is the name and rank of every company ordered by descending number of sales?
Additional table information: table: gas_company

Answer: SELECT company, rank FROM company ORDER BY Sales_billion DESC


Question:
Show the most common nationality for journalists.
Additional table information: table: news_report

Answer: SELECT Nationality FROM journalist GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1


Question:
How many students are older than 20 in each dorm?
Additional table information: table: dorm_1

Answer: SELECT COUNT(*), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name


Question:
Which problems were reported before the date of any problem reported by the staff Lysanne Turcotte? Give me the ids of the problems.
Additional table information: table: tracking_software_problems

Answer: SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < (SELECT MIN(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = 'Lysanne' AND T4.staff_last_name = 'Turcotte')


Question:
Which students are advised by Michael Goodrich? Give me their first and last names.
Additional table information: table: activity_1

Answer: SELECT T2.fname, T2.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor WHERE T1.fname = 'Michael' AND T1.lname = 'Goodrich'


Question:
For each submission, find its author and acceptance result.
Additional table information: table: workshop_paper

Answer: SELECT T2.Author, T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID


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

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


Question:
Find the names of districts where have both city mall and village store type stores.
Additional table information: table: store_product

Answer: SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = 'City Mall' INTERSECT SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = 'Village Store'


Question:
Find the distinct majors of students who have treasurer votes.
Additional table information: table: voter_2

Answer: SELECT DISTINCT T1.Major FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.Treasurer_Vote


Question:
What are all the phone numbers?
Additional table information: table: insurance_fnol

Answer: SELECT customer_phone FROM available_policies


Question:
What are the manager's first name, last name and id who won the most manager award?
Additional table information: table: baseball_1

Answer: SELECT T1.name_first, T1.name_last, T2.player_id FROM player AS T1 JOIN manager_award AS T2 ON T1.player_id = T2.player_id GROUP BY T2.player_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the names of products with 'white' as their color description?
Additional table information: table: products_gen_characteristics

Answer: SELECT t1.product_name FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code WHERE t2.color_description = 'white'


Question:
Show each apartment type code, and the maximum and minimum number of rooms for each type.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, MAX(room_count), MIN(room_count) FROM Apartments GROUP BY apt_type_code


Question:
How many total credits are offered by each department?
Additional table information: table: college_2

Answer: SELECT SUM(credits), dept_name FROM course GROUP BY dept_name


Question:
Find the count and code of the job has most employees.
Additional table information: table: college_1

Answer: SELECT emp_jobcode, COUNT(*) FROM employee GROUP BY emp_jobcode ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the names of all music genres.
Additional table information: table: chinook_1

Answer: SELECT Name FROM GENRE


Question:
What is the average price for flights from Los Angeles to Honolulu.
Additional table information: table: flight_1

Answer: SELECT AVG(price) FROM Flight WHERE origin = 'Los Angeles' AND destination = 'Honolulu'


Question:
Show the nicknames of schools that are not in division 1.
Additional table information: table: school_player

Answer: SELECT Nickname FROM school_details WHERE Division <> 'Division 1'


Question:
List how many times the number of people in the room reached the maximum occupancy of the room. The number of people include adults and kids.
Additional table information: table: inn_1

Answer: SELECT COUNT(*) FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T2.maxOccupancy = T1.Adults + T1.Kids


Question:
How many different levels do members have?
Additional table information: table: shop_membership

Answer: SELECT COUNT(DISTINCT LEVEL) FROM member


Question:
Find the claim id and the number of settlements made for the claim with the most recent settlement date.
Additional table information: table: insurance_policies

Answer: SELECT COUNT(*), T1.claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY T1.Date_Claim_Settled DESC LIMIT 1


Question:
What is the first name and age of every student who lives in a dorm with a TV Lounge?
Additional table information: table: dorm_1

Answer: SELECT T1.fname, T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE NOT T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')


Question:
Show different colleges along with the number of authors of submission from each college.
Additional table information: table: workshop_paper

Answer: SELECT College, COUNT(*) FROM submission GROUP BY College


Question:
What is the name of the product with the highest price?
Additional table information: table: solvency_ii

Answer: SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1


Question:
Find the number of schools that have more than one donator whose donation amount is less than 8.5.
Additional table information: table: school_finance

Answer: SELECT COUNT(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING COUNT(*) > 1)


Question:
Return the titles of any movies with an R rating.
Additional table information: table: sakila_1

Answer: SELECT title FROM film WHERE rating = 'R'


Question:
Find the name of the nurse who has the largest number of appointments.
Additional table information: table: hospital_1

Answer: SELECT T1.name FROM nurse AS T1 JOIN appointment AS T2 ON T1.employeeid = T2.prepnurse GROUP BY T1.employeeid ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the names and decor of rooms that have a king bed. Sort the list by their price.
Additional table information: table: inn_1

Answer: SELECT roomName, decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice NULLS FIRST


Question:
Which campus has the most degrees conferred in all times?
Additional table information: table: csu_1

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


Question:
Compute the total amount of payment processed.
Additional table information: table: insurance_policies

Answer: SELECT SUM(Amount_Payment) FROM Payments


Question:
What are the names of companies whose headquarters are not 'USA'?
Additional table information: table: company_office

Answer: SELECT name FROM Companies WHERE Headquarters <> 'USA'


Question:
What is the average amount due for all the payments?
Additional table information: table: products_for_hire

Answer: SELECT AVG(amount_due) FROM payments


Question:
Show institution names along with the number of proteins for each institution.
Additional table information: table: protein_institute

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


Question:
What is the last name of every student who is either female or living in a city with the code BAL or male and under 20?
Additional table information: table: dorm_1

Answer: SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20


Question:
What are the names of mountains that have a height of over 5000 or a prominence of over 1000?
Additional table information: table: climbing

Answer: SELECT Name FROM mountain WHERE Height > 5000 OR Prominence > 1000


Question:
What are the id and zip code of the address with the highest monthly rental?
Additional table information: table: behavior_monitoring

Answer: SELECT T2.address_id, T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id ORDER BY monthly_rental DESC LIMIT 1


Question:
Find the country of origin for the artist who made the least number of songs?
Additional table information: table: music_1

Answer: SELECT T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name GROUP BY T2.artist_name ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
What is the first name of the student whose last name starts with the letter S and is taking ACCT-211?
Additional table information: table: college_1

Answer: SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code WHERE T3.crs_code = 'ACCT-211' AND T1.stu_lname LIKE 'S%'


Question:
Tell me the highest, lowest, and average cost of procedures.
Additional table information: table: hospital_1

Answer: SELECT MAX(cost), MIN(cost), AVG(cost) FROM procedures


Question:
What are the names and locations of all enzymes listed?
Additional table information: table: medicine_enzyme_interaction

Answer: SELECT name, LOCATION FROM enzyme


Question:
Find the names of all swimmers, sorted by their 100 meter scores in ascending order.
Additional table information: table: swimming

Answer: SELECT name FROM swimmer ORDER BY meter_100 NULLS FIRST


Question:
Show the distinct director of films with market estimation in the year of 1995.
Additional table information: table: film_rank

Answer: SELECT DISTINCT T1.Director FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID WHERE T2.Year = 1995


Question:
What are the students ids of students who have more than one allergy?
Additional table information: table: allergy_1

Answer: SELECT StuID FROM Has_allergy GROUP BY StuID HAVING COUNT(*) >= 2


Question:
List document type codes and the number of documents in each code.
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT document_type_code, COUNT(*) FROM Documents GROUP BY document_type_code


Question:
Return all information about employees with salaries between 8000 and 12000 for which commission is not null or where their department id is not 40.
Additional table information: table: hr_1

Answer: SELECT * FROM employees WHERE salary BETWEEN 8000 AND 12000 AND commission_pct <> 'null' OR department_id <> 40


Question:
What are the positions of both players that have more than 20 20 points and less than 10 points?
Additional table information: table: sports_competition

Answer: SELECT POSITION FROM player WHERE Points > 20 INTERSECT SELECT POSITION FROM player WHERE Points < 10


Question:
Find the name of bank branch that provided the greatest total amount of loans.
Additional table information: table: loan_1

Answer: SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY SUM(T2.amount) DESC LIMIT 1


Question:
Return the famous release date for the oldest artist.
Additional table information: table: music_4

Answer: SELECT Famous_Release_date FROM artist ORDER BY Age DESC LIMIT 1


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

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


Question:
Show the names of customers who use Credit Card payment method and have more than 2 orders.
Additional table information: table: customers_and_products_contacts

Answer: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.payment_method_code = 'Credit Card' GROUP BY T1.customer_id HAVING COUNT(*) > 2


Question:
Find the number of companies whose industry is 'Banking' or 'Conglomerate',
Additional table information: table: company_office

Answer: SELECT COUNT(*) FROM Companies WHERE Industry = 'Banking' OR Industry = 'Conglomerate'


Question:
How many employees do we have?
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT COUNT(*) FROM Employees


Question:
What is the name of the department with the fewest professors?
Additional table information: table: college_1

Answer: SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
What are the durations of the longest and the shortest tracks in milliseconds?
Additional table information: table: chinook_1

Answer: SELECT MAX(Milliseconds), MIN(Milliseconds) FROM TRACK


Question:
How many tests have result 'Fail'?
Additional table information: table: e_learning

Answer: SELECT COUNT(*) FROM Student_Tests_Taken WHERE test_result = 'Fail'


Question:
Find Alice's friends of friends.
Additional table information: table: network_2

Answer: SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name <> 'Alice'


Question:
Find the name of customers who have loans of both Mortgages and Auto.
Additional table information: table: loan_1

Answer: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Mortgages' INTERSECT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Auto'


Question:
List the name of playlist which has number of tracks greater than 100.
Additional table information: table: store_1

Answer: SELECT T2.name FROM playlist_tracks AS T1 JOIN playlists AS T2 ON T2.id = T1.playlist_id GROUP BY T1.playlist_id HAVING COUNT(T1.track_id) > 100


Question:
Which catalog publishers have substring 'Murray' in their names?
Additional table information: table: product_catalog

Answer: SELECT DISTINCT (catalog_publisher) FROM catalogs WHERE catalog_publisher LIKE '%Murray%'


Question:
For all directors who directed more than one movie, return the titles of all movies directed by them, along with the director name. Sort by director name, then movie title.
Additional table information: table: movie_1

Answer: SELECT T1.title, T1.director FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title <> T2.title ORDER BY T1.director NULLS FIRST, T1.title NULLS FIRST


Question:
List the name of technicians whose team is not 'NYY'.
Additional table information: table: machine_repair

Answer: SELECT Name FROM technician WHERE Team <> 'NYY'


Question:
List the enrollment for each school that does not have 'Catholic' as denomination.
Additional table information: table: school_player

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


Question:
What are the ids of all students who have attended at least one course?
Additional table information: table: student_assessment

Answer: SELECT student_id FROM student_course_attendance


Question:
Show ids of students who don't play video game.
Additional table information: table: game_1

Answer: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games


Question:
Show the number of transaction types.
Additional table information: table: customers_card_transactions

Answer: SELECT COUNT(DISTINCT transaction_type) FROM Financial_Transactions


Question:
Show the total number of rooms of the apartments in the building with short name 'Columbus Square'.
Additional table information: table: apartment_rentals

Answer: SELECT SUM(T2.room_count) FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id = T2.building_id WHERE T1.building_short_name = 'Columbus Square'