Question:
Return the most common first name among all actors.
Additional table information: table: sakila_1

Answer: SELECT first_name FROM actor GROUP BY first_name ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the type codes of the policies used by the customer 'Dayana Robel'?
Additional table information: table: insurance_and_eClaims

Answer: SELECT policy_type_code FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t2.customer_details = 'Dayana Robel'


Question:
What are the names of all the tracks that are in both the 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:
Show the delegates and the names of the party they belong to.
Additional table information: table: election

Answer: SELECT T1.Delegate, T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID


Question:
display the full name (first and last name), and salary of those employees who working in any department located in London.
Additional table information: table: hr_1

Answer: SELECT first_name, last_name, salary FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id WHERE T3.city = 'London'


Question:
Compute the total salary that the player with first name Len and last name Barker received between 1985 to 1990.
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:
What are the name, id and the corresponding number of visits for each  tourist attraction?
Additional table information: table: cre_Theme_park

Answer: SELECT T1.Name, T2.Tourist_Attraction_ID, COUNT(*) FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID GROUP BY T2.Tourist_Attraction_ID


Question:
What are the method, date and amount of each payment? Sort the list in ascending order of date.
Additional table information: table: insurance_policies

Answer: SELECT Payment_Method_Code, Date_Payment_Made, Amount_Payment FROM Payments ORDER BY Date_Payment_Made ASC NULLS FIRST


Question:
List the first name and last name of all customers.
Additional table information: table: driving_school

Answer: SELECT first_name, last_name FROM Customers


Question:
Show the name and location for all tracks.
Additional table information: table: race_track

Answer: SELECT name, LOCATION FROM track


Question:
List the name, born state and age of the heads of departments ordered by age.
Additional table information: table: department_management

Answer: SELECT name, born_state, age FROM head ORDER BY age NULLS FIRST


Question:
Find the title, credit, and department name of courses that have more than one prerequisites?
Additional table information: table: college_2

Answer: SELECT T1.title, T1.credits, T1.dept_name FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING COUNT(*) > 1


Question:
How many airports are there per city in the US ordered from most to least?
Additional table information: table: flight_4

Answer: SELECT COUNT(*), city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY COUNT(*) DESC


Question:
Show all role codes and the number of employees in each role.
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT role_code, COUNT(*) FROM Employees GROUP BY role_code


Question:
What is the id and detail of the vehicle used in lessons for most of the times?
Additional table information: table: driving_school

Answer: SELECT T1.vehicle_id, T1.vehicle_details FROM Vehicles AS T1 JOIN Lessons AS T2 ON T1.vehicle_id = T2.vehicle_id GROUP BY T1.vehicle_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
List the dates and vote percents of elections.
Additional table information: table: election_representative

Answer: SELECT Date, Vote_Percent FROM election


Question:
List the names of mountains that do not have any climber.
Additional table information: table: climbing

Answer: SELECT Name FROM mountain WHERE NOT Mountain_ID IN (SELECT Mountain_ID FROM climber)


Question:
What is the average total number of passengers of airports that are associated with aircraft 'Robinson R-22'?
Additional table information: table: aircraft

Answer: SELECT AVG(T3.Total_Passengers) FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID = T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID = T3.Airport_ID WHERE T1.Aircraft = 'Robinson R-22'


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

Answer: SELECT name FROM instructor WHERE NOT id IN (SELECT id FROM teaches)


Question:
How many distinct official languages are there among countries of players whose positions are defenders.
Additional table information: table: match_season

Answer: SELECT COUNT(DISTINCT T1.Official_native_language) FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.Position = 'Defender'


Question:
Retrieve the country that has published the most papers.
Additional table information: table: icfp_1

Answer: SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.country ORDER BY COUNT(*) DESC LIMIT 1


Question:
What destination has the fewest number of flights?
Additional table information: table: flight_1

Answer: SELECT destination FROM Flight GROUP BY destination ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
Return the channel code and contact number of the customer contact channel whose active duration was the longest.
Additional table information: table: customers_and_addresses

Answer: SELECT channel_code, contact_number FROM customer_contact_channels WHERE active_to_date - active_from_date = (SELECT active_to_date - active_from_date FROM customer_contact_channels ORDER BY (active_to_date - active_from_date) DESC LIMIT 1)


Question:
What is the average high temperature for each day of week?
Additional table information: table: station_weather

Answer: SELECT AVG(high_temperature), day_of_week FROM weekly_weather GROUP BY day_of_week


Question:
How many distinct publication dates are there in our record?
Additional table information: table: book_2

Answer: SELECT COUNT(DISTINCT Publication_Date) FROM publication


Question:
What are the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa?
Additional table information: table: sakila_1

Answer: SELECT payment_date FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa'


Question:
What is the average number of stars that each reviewer awards for a movie?
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:
Please list the years of film market estimations when the market is in country 'Japan' in descending order.
Additional table information: table: film_rank

Answer: SELECT T1.Year FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T2.Country = 'Japan' ORDER BY T1.Year DESC


Question:
Find the number of students whose city code is NYC and who have class senator votes in the spring election cycle.
Additional table information: table: voter_2

Answer: SELECT COUNT(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = Class_Senator_Vote WHERE T1.city_code = 'NYC' AND T2.Election_Cycle = 'Spring'


Question:
What are all the addresses in East Julianaside, Texas or in Gleasonmouth, Arizona.
Additional table information: table: customers_and_addresses

Answer: SELECT address_content FROM addresses WHERE city = 'East Julianaside' AND state_province_county = 'Texas' UNION SELECT address_content FROM addresses WHERE city = 'Gleasonmouth' AND state_province_county = 'Arizona'


Question:
What are the first and last names of the instructors who teach the top 3 number of courses?
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 GROUP BY T1.Instructor ORDER BY COUNT(*) DESC LIMIT 3


Question:
Return the ids of all products that were ordered more than three times or supplied more than 80000.
Additional table information: table: department_store

Answer: SELECT product_id FROM Order_Items GROUP BY product_id HAVING COUNT(*) > 3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING SUM(total_amount_purchased) > 80000


Question:
What is the salaray and name of the employee with the most certificates to fly planes more than 5000?
Additional table information: table: flight_1

Answer: SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.distance > 5000 GROUP BY T1.eid ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which campus has the most faculties in year 2003?
Additional table information: table: csu_1

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


Question:
Which is the email of the party that has used the services the most number of times?
Additional table information: table: e_government

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


Question:
Show the distinct fate of missions that involve ships with nationality 'United States'
Additional table information: table: ship_mission

Answer: SELECT DISTINCT T1.Fate FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID WHERE T2.Nationality = 'United States'


Question:
How many hours do the students spend studying in each department?
Additional table information: table: college_1

Answer: SELECT SUM(stu_hrs), dept_code FROM student GROUP BY dept_code


Question:
Return the age of the person with the greatest height.
Additional table information: table: gymnast

Answer: SELECT Age FROM people ORDER BY Height DESC LIMIT 1


Question:
Find the name and account balance of the customers who have loans with a total amount of more than 5000.
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:
How many rooms whose capacity is less than 50 does the Lamberton building have?
Additional table information: table: college_2

Answer: SELECT COUNT(*) FROM classroom WHERE building = 'Lamberton' AND capacity < 50


Question:
Show ids for all students who live in CHI.
Additional table information: table: game_1

Answer: SELECT StuID FROM Student WHERE city_code = 'CHI'


Question:
Find the last names of students with major 50.
Additional table information: table: voter_2

Answer: SELECT LName FROM STUDENT WHERE Major = 50


Question:
What is the unit of measurement of product named 'cumin'?
Additional table information: table: products_gen_characteristics

Answer: SELECT t2.unit_of_measure FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code = t2.product_category_code WHERE t1.product_name = 'cumin'


Question:
Find the component amounts and names of all furnitures that have more than 10 components.
Additional table information: table: manufacturer

Answer: SELECT Num_of_Component, name FROM furniture WHERE Num_of_Component > 10


Question:
What are the details of the project with no outcomes?
Additional table information: table: tracking_grants_for_research

Answer: SELECT project_details FROM Projects WHERE NOT project_id IN (SELECT project_id FROM Project_outcomes)


Question:
display the employee name ( first name and last name ) and hire date for all employees in the same department as Clara.
Additional table information: table: hr_1

Answer: SELECT first_name, last_name, hire_date FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE first_name = 'Clara')


Question:
Which of the mill names contains the french word 'Moulin'?
Additional table information: table: architecture

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


Question:
What are the first names of all students in Smith Hall?
Additional table information: table: dorm_1

Answer: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'


Question:
List the types of competition that have at most five competitions of that type.
Additional table information: table: sports_competition

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


Question:
list names of all departments ordered by their names.
Additional table information: table: college_1

Answer: SELECT dept_name FROM department ORDER BY dept_name NULLS FIRST


Question:
Please show the employee first names and ids of employees who serve at least 10 customers.
Additional table information: table: chinook_1

Answer: SELECT T1.FirstName, T1.SupportRepId FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) >= 10


Question:
What are the names of the districts that have both mall and village store style shops?
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:
List the open date of open year of the shop named 'Apple'.
Additional table information: table: device

Answer: SELECT Open_Date, Open_Year FROM shop WHERE Shop_Name = 'Apple'


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

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


Question:
Find the names of users who did not leave any review.
Additional table information: table: epinions_1

Answer: SELECT name FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)


Question:
Provide the full names of employees earning more than the employee with id 163.
Additional table information: table: hr_1

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


Question:
Return the text of tweets about the topic 'intern'.
Additional table information: table: twitter_1

Answer: SELECT text FROM tweets WHERE text LIKE '%intern%'


Question:
Find the name of customers who are living in Colorado?
Additional table information: table: customers_and_addresses

Answer: SELECT t1.customer_name FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'Colorado'


Question:
Return the result that is most frequent at music festivals.
Additional table information: table: music_4

Answer: SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the number of songs in all the studio albums.
Additional table information: table: music_2

Answer: SELECT COUNT(DISTINCT T3.title) FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.type = 'Studio'


Question:
What are the names and salaries for instructors who earn less than the average salary of instructors in the Physics department?
Additional table information: table: college_2

Answer: SELECT name, salary FROM instructor WHERE salary < (SELECT AVG(salary) FROM instructor WHERE dept_name = 'Physics')


Question:
What is the full name of the staff member who has rented a film to a customer with the first name April and the last name Burns?
Additional table information: table: sakila_1

Answer: SELECT DISTINCT T1.first_name, T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS'


Question:
List the name of all products along with the number of complaints that they have 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:
Return the prices of wines produced before 2010.
Additional table information: table: wine_1

Answer: SELECT Price FROM WINE WHERE YEAR < 2010


Question:
Show different carriers of phones together with the number of phones with each carrier.
Additional table information: table: phone_market

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


Question:
Which customers use 'Cash' for payment method? Return the customer names.
Additional table information: table: customers_and_addresses

Answer: SELECT customer_name FROM customers WHERE payment_method = 'Cash'


Question:
Find the number of scientists who are not assigned to any project.
Additional table information: table: scientist_1

Answer: SELECT COUNT(*) FROM scientists WHERE NOT ssn IN (SELECT scientist FROM AssignedTo)


Question:
Find the names and number of works of all artists who have at least one English songs.
Additional table information: table: music_1

Answer: SELECT T1.artist_name, COUNT(*) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.languages = 'english' GROUP BY T2.artist_name HAVING COUNT(*) >= 1


Question:
What are the famous titles of artists who have not only had volumes that spent more than 2 weeks on top but also volumes that spent less than 2 weeks on top?
Additional table information: table: music_4

Answer: SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2 INTERSECT SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top < 2


Question:
What is the total balance of savings accounts not belonging to someone with the name Brown?
Additional table information: table: small_bank_1

Answer: SELECT SUM(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T1.name <> 'Brown'


Question:
Find the types of documents with more than 4 documents.
Additional table information: table: document_management

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


Question:
Find the first names of all the authors ordered in alphabetical order.
Additional table information: table: icfp_1

Answer: SELECT fname FROM authors ORDER BY fname NULLS FIRST


Question:
How many people whose age is greater 30 and job is engineer?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE age > 30 AND job = 'engineer'


Question:
What is the description of the product category with the code 'Spices'?
Additional table information: table: products_gen_characteristics

Answer: SELECT product_category_description FROM ref_product_categories WHERE product_category_code = 'Spices'


Question:
What are the names of every person who has a friend over 40 and under 30?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)


Question:
What is the total amount of payment?
Additional table information: table: insurance_policies

Answer: SELECT SUM(Amount_Payment) FROM Payments


Question:
What are the first and last names of the first-grade students who are NOT taught by teacher OTHA MOYER?
Additional table information: table: student_1

Answer: SELECT DISTINCT T1.firstname, T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.grade = 1 EXCEPT SELECT T1.firstname, T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = 'OTHA' AND T2.lastname = 'MOYER'


Question:
Find the name of dorms which have both TV Lounge and Study Room as amenities.
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' INTERSECT 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:
How many different last names do the actors and actresses have?
Additional table information: table: sakila_1

Answer: SELECT COUNT(DISTINCT last_name) FROM actor


Question:
Show the first name and last name for the customer with account name 900.
Additional table information: table: customers_and_invoices

Answer: SELECT T2.customer_first_name, T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.account_name = '900'


Question:
For each station, find its latitude and the minimum duration of trips that ended at the station.
Additional table information: table: bike_1

Answer: SELECT T1.name, T1.lat, MIN(T2.duration) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.end_station_id GROUP BY T2.end_station_id


Question:
Return the number of customers who have at least one order with 'Cancelled' status.
Additional table information: table: customers_and_addresses

Answer: SELECT COUNT(DISTINCT customer_id) FROM customer_orders WHERE order_status = 'Cancelled'


Question:
What are the names of the directors who made exactly one movie?
Additional table information: table: movie_1

Answer: SELECT director FROM Movie GROUP BY director HAVING COUNT(*) = 1


Question:
What are the names of the singers who sang the top 3 most highly rated songs and what countries do they hail from?
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 ORDER BY T2.rating DESC LIMIT 3


Question:
Find the number of employees whose title is IT Staff from each city?
Additional table information: table: store_1

Answer: SELECT COUNT(*), city FROM employees WHERE title = 'IT Staff' GROUP BY city


Question:
What are the average prices of hotels grouped by their pet policy.
Additional table information: table: cre_Theme_park

Answer: SELECT pets_allowed_yn, AVG(price_range) FROM HOTELS GROUP BY pets_allowed_yn


Question:
Find the salary and manager number for those employees who is working under a manager.
Additional table information: table: hr_1

Answer: SELECT salary, manager_id FROM employees WHERE manager_id <> 'null'


Question:
What are the three most costly procedures?
Additional table information: table: hospital_1

Answer: SELECT name FROM procedures ORDER BY cost NULLS FIRST LIMIT 3


Question:
Find the the grape whose white color grapes are used to produce wines with scores higher than 90.
Additional table information: table: wine_1

Answer: SELECT DISTINCT T1.Grape FROM GRAPES AS T1 JOIN WINE AS T2 ON T1.Grape = T2.Grape WHERE T1.Color = 'White' AND T2.score > 90


Question:
How many donors have endowment for school named 'Glenn'?
Additional table information: table: school_finance

Answer: SELECT COUNT(DISTINCT T1.donator_name) FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'


Question:
What are the open and close dates of all the policies used by the customer who have 'Diana' in part of their names?
Additional table information: table: insurance_fnol

Answer: SELECT t2.date_opened, t2.date_closed FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name LIKE '%Diana%'


Question:
Count the number of budget codes.
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT COUNT(*) FROM Ref_budget_codes


Question:
List all document type codes and document type names.
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT document_type_code, document_type_name FROM Ref_document_types


Question:
What are the names of all the scientists in alphabetical order?
Additional table information: table: scientist_1

Answer: SELECT name FROM scientists ORDER BY name NULLS FIRST


Question:
Find all types of store and number of them.
Additional table information: table: store_product

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


Question:
what are the name of players who get more than the average points.
Additional table information: table: sports_competition

Answer: SELECT name FROM player WHERE points > (SELECT AVG(points) FROM player)


Question:
How many milliseconds long is Fast As a Shark?
Additional table information: table: store_1

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


Question:
Find the names of rooms that have been reserved for more than 60 times.
Additional table information: table: inn_1

Answer: SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room HAVING COUNT(*) > 60


Question:
Give the title and credits for the course that is taught in the classroom with the greatest capacity.
Additional table information: table: college_2

Answer: SELECT T3.title, T3.credits FROM classroom AS T1 JOIN SECTION AS T2 ON T1.building = T2.building AND T1.room_number = T2.room_number JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.capacity = (SELECT MAX(capacity) FROM classroom)


Question:
What is the id of the patient who stayed in room 111 most recently?
Additional table information: table: hospital_1

Answer: SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1


Question:
How many addresses are in the district of California?
Additional table information: table: sakila_1

Answer: SELECT COUNT(*) FROM address WHERE district = 'California'


Question:
Show the ids and names of all documents.
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT document_id, document_name FROM Documents


Question:
Which artist has the most albums?
Additional table information: table: chinook_1

Answer: SELECT T2.Name FROM ALBUM AS T1 JOIN ARTIST AS T2 ON T1.ArtistId = T2.ArtistId GROUP BY T2.Name ORDER BY COUNT(*) DESC LIMIT 1


Question:
What is the title, phone and hire date of Nancy Edwards?
Additional table information: table: store_1

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


Question:
What is the average weight of all players?
Additional table information: table: soccer_1

Answer: SELECT AVG(weight) FROM Player


Question:
What is the marketing region code that has the most drama workshop groups?
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT Marketing_Region_Code FROM Drama_Workshop_Groups GROUP BY Marketing_Region_Code ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the delegate and committee information for each election record?
Additional table information: table: election

Answer: SELECT Delegate, Committee FROM election


Question:
What are the prices of products that have never gotten a complaint?
Additional table information: table: customer_complaints

Answer: SELECT product_price FROM products WHERE NOT product_id IN (SELECT product_id FROM complaints)


Question:
Return the detail of the location named 'UK Gallery'.
Additional table information: table: cre_Theme_park

Answer: SELECT Other_Details FROM LOCATIONS WHERE Location_Name = 'UK Gallery'


Question:
Give the country id and corresponding count of cities in each country.
Additional table information: table: hr_1

Answer: SELECT country_id, COUNT(*) FROM locations GROUP BY country_id


Question:
Find the average checking balance.
Additional table information: table: small_bank_1

Answer: SELECT AVG(balance) FROM checking


Question:
Show the station name with greatest number of trains.
Additional table information: table: train_station

Answer: SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the course names, ordered by credits?
Additional table information: table: college_3

Answer: SELECT CName FROM COURSE ORDER BY Credits NULLS FIRST


Question:
Find the name of the person who has friends with age above 40 and under age 30?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30)


Question:
Find the name of the ships that have more than one captain.
Additional table information: table: ship_1

Answer: SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id GROUP BY t2.ship_id HAVING COUNT(*) > 1


Question:
Count the total number of policies used by the customer named 'Dayana Robel'.
Additional table information: table: insurance_fnol

Answer: SELECT COUNT(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = 'Dayana Robel'


Question:
Find the number of airports whose name contain the word 'International'.
Additional table information: table: flight_4

Answer: SELECT COUNT(*) FROM airports WHERE name LIKE '%International%'


Question:
Find the name of instructors who are advising more than one student.
Additional table information: table: college_2

Answer: SELECT T1.name FROM instructor AS T1 JOIN advisor AS T2 ON T1.id = T2.i_id GROUP BY T2.i_id HAVING COUNT(*) > 1


Question:
For each payment method, return how many customers use it.
Additional table information: table: department_store

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


Question:
List all the contact channel codes that were used less than 5 times.
Additional table information: table: customers_and_addresses

Answer: SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING COUNT(customer_id) < 5


Question:
What are the number of international and domestic passengers of the airport named London 'Heathrow'?
Additional table information: table: aircraft

Answer: SELECT International_Passengers, Domestic_Passengers FROM airport WHERE Airport_Name = 'London Heathrow'


Question:
What is the first and last name of the employee who reports to Nancy Edwards?
Additional table information: table: store_1

Answer: SELECT T2.first_name, T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = 'Nancy' AND T1.last_name = 'Edwards'


Question:
How many different users wrote some reviews?
Additional table information: table: epinions_1

Answer: SELECT COUNT(DISTINCT u_id) FROM review


Question:
What are the member names and hometowns of those who registered at 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:
Find all the zip codes in which the max dew point have never reached 70.
Additional table information: table: bike_1

Answer: SELECT DISTINCT zip_code FROM weather EXCEPT SELECT DISTINCT zip_code FROM weather WHERE max_dew_point_f >= 70


Question:
What are the the songs in volumes, listed in ascending order?
Additional table information: table: music_4

Answer: SELECT Song FROM volume ORDER BY Song NULLS FIRST


Question:
Find the claims that led to more than two settlements or have the maximum claim value. For each of them, return the date the claim was made and the id of the claim.
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:
Give id of the instructor who advises students in the History department.
Additional table information: table: college_2

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


Question:
What are the names of all reviewers that have given 3 or 4 stars for reviews?
Additional table information: table: movie_1

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


Question:
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.
Additional table information: table: department_management

Answer: SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Homeland Security'


Question:
Find all the songs that do not have a lead vocal.
Additional table information: table: music_2

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


Question:
What is the customer first, last name and id with least number of accounts.
Additional table information: table: customers_card_transactions

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


Question:
Count the number of wines produced at Robert Biale winery.
Additional table information: table: wine_1

Answer: SELECT COUNT(*) FROM WINE WHERE Winery = 'Robert Biale'


Question:
Show the location code, the starting date and ending data in that location for all the documents.
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT location_code, date_in_location_from, date_in_locaton_to FROM Document_locations


Question:
Find the first names of professors who are not playing Canoeing or Kayaking.
Additional table information: table: activity_1

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


Question:
What is the date of birth of every customer whose status code is 'Good Customer'?
Additional table information: table: driving_school

Answer: SELECT date_of_birth FROM Customers WHERE customer_status_code = 'Good Customer'


Question:
What is the average song duration for the songs that are in mp3 format and whose resolution below 800?
Additional table information: table: music_1

Answer: SELECT AVG(T1.duration) FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.formats = 'mp3' AND T2.resolution < 800


Question:
What are the songs in album 'A Kiss Before You Go: Live in Hamburg'?
Additional table information: table: music_2

Answer: SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE T1.title = 'A Kiss Before You Go: Live in Hamburg'


Question:
What are the names and urls of images, sorted alphabetically?
Additional table information: table: document_management

Answer: SELECT image_name, image_url FROM images ORDER BY image_name NULLS FIRST


Question:
How many different jobs are listed?
Additional table information: table: network_2

Answer: SELECT COUNT(DISTINCT job) FROM Person


Question:
Find the 'date became customers' of the customers whose ID is between 10 and 20.
Additional table information: table: customers_and_addresses

Answer: SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20


Question:
Find the code of the role that have the most 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:
What are the main indstries and total market value for each industry?
Additional table information: table: gas_company

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


Question:
List the first name of all employees with job code PROF ordered by their date of birth.
Additional table information: table: college_1

Answer: SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob NULLS FIRST


Question:
How many students are in each department?
Additional table information: table: college_2

Answer: SELECT COUNT(*), dept_name FROM student GROUP BY dept_name


Question:
what is the name of the instructor who is in Statistics department and earns the lowest salary?
Additional table information: table: college_2

Answer: SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary NULLS FIRST LIMIT 1


Question:
What is the first and last name of the faculty participating in the most activities?
Additional table information: table: activity_1

Answer: SELECT T1.fname, T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID GROUP BY T1.FacID ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the number of papers published by authors from the institution 'Tokohu University'.
Additional table information: table: icfp_1

Answer: SELECT COUNT(DISTINCT t1.title) FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = 'Tokohu University'


Question:
Find the saving balance of the account with the highest checking balance.
Additional table information: table: small_bank_1

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


Question:
What is the title of the course that was offered at building Chandler during the fall semester in the year of 2010?
Additional table information: table: college_2

Answer: SELECT T1.title FROM course AS T1 JOIN SECTION AS T2 ON T1.course_id = T2.course_id WHERE building = 'Chandler' AND semester = 'Fall' AND YEAR = 2010


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

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


Question:
What are the names of projects that require between 100 and 300 hours?
Additional table information: table: scientist_1

Answer: SELECT name FROM projects WHERE hours BETWEEN 100 AND 300


Question:
Show all card type codes and the number of customers holding cards in each type.
Additional table information: table: customers_card_transactions

Answer: SELECT card_type_code, COUNT(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code


Question:
Which months have more than 2 happy hours?
Additional table information: table: coffee_shop

Answer: SELECT MONTH FROM happy_hour GROUP BY MONTH HAVING COUNT(*) > 2


Question:
Show the outcome code of mailshots along with the number of mailshots in each outcome code.
Additional table information: table: customers_campaigns_ecommerce

Answer: SELECT outcome_code, COUNT(*) FROM mailshot_customers GROUP BY outcome_code


Question:
What is the average rating of songs for each language?
Additional table information: table: music_1

Answer: SELECT AVG(rating), languages FROM song GROUP BY languages


Question:
Show student ids who don't have any sports.
Additional table information: table: game_1

Answer: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo


Question:
Take the average of the school enrollment.
Additional table information: table: school_player

Answer: SELECT AVG(Enrollment) FROM school


Question:
What are the names of musicals who have at 3 or more actors?
Additional table information: table: musical

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


Question:
How many players have more than 1000 hours of training?
Additional table information: table: soccer_2

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


Question:
What are the names and ids of stations that had more than 14 bikes available on average or were installed in December?
Additional table information: table: bike_1

Answer: SELECT T1.name, T1.id FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING AVG(T2.bikes_available) > 14 UNION SELECT name, id FROM station WHERE installation_date LIKE '12/%'


Question:
What are the name and description for role code 'MG'?
Additional table information: table: cre_Doc_Tracking_DB

Answer: SELECT role_name, role_description FROM ROLES WHERE role_code = 'MG'


Question:
Show details of all visitors.
Additional table information: table: cre_Theme_park

Answer: SELECT Tourist_Details FROM VISITORS


Question:
How many lessons did the customer Ryan Goodwin complete?
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 = 'Rylan' AND T2.last_name = 'Goodwin' AND T1.lesson_status_code = 'Completed'


Question:
Find the name of the ships that are steered by both a captain with Midshipman rank and a captain with Lieutenant rank.
Additional table information: table: ship_1

Answer: SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Midshipman' INTERSECT SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Lieutenant'


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

Answer: SELECT station_id, LOCATION, manager_name FROM gas_station ORDER BY open_year NULLS FIRST


Question:
How many roller coasters are there?
Additional table information: table: roller_coaster

Answer: SELECT COUNT(*) FROM roller_coaster


Question:
Find the first name and last name and department id for those employees who earn such amount of salary which is the smallest salary of any of the departments.
Additional table information: table: hr_1

Answer: SELECT first_name, last_name, department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id)


Question:
What is the average and largest salary of all employees?
Additional table information: table: flight_1

Answer: SELECT AVG(salary), MAX(salary) FROM Employee


Question:
What are all the policy types of the customer that has the most policies listed?
Additional table information: table: insurance_fnol

Answer: SELECT DISTINCT t3.policy_type_code FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id JOIN available_policies AS t3 ON t2.policy_id = t3.policy_id WHERE t1.customer_name = (SELECT t1.customer_name FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_name ORDER BY COUNT(*) DESC LIMIT 1)


Question:
What is the average sales of the journals that have an editor whose work type is 'Photo'?
Additional table information: table: journal_committee

Answer: SELECT AVG(T1.sales) FROM journal AS T1 JOIN journal_committee AS T2 ON T1.journal_ID = T2.journal_ID WHERE T2.work_type = 'Photo'


Question:
Find the names of customers who have used both the service 'Close a policy' and the service 'New policy application'.
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' INTERSECT 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 = 'New policy application'


Question:
list the local authorities and services provided by all stations.
Additional table information: table: station_weather

Answer: SELECT local_authority, services FROM station


Question:
Find the payment method that is used most frequently.
Additional table information: table: customers_and_addresses

Answer: SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are full names and salaries of employees working in the city of London?
Additional table information: table: hr_1

Answer: SELECT first_name, last_name, salary FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id WHERE T3.city = 'London'


Question:
What is the maximum and minimum market value of companies?
Additional table information: table: company_employee

Answer: SELECT MAX(Market_Value_in_Billion), MIN(Market_Value_in_Billion) FROM company


Question:
Find all the ids and dates of the logs for the problem whose id is 10.
Additional table information: table: tracking_software_problems

Answer: SELECT problem_log_id, log_entry_date FROM problem_log WHERE problem_id = 10


Question:
What are the themes of farm competitions sorted by year in ascending order?
Additional table information: table: farm

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


Question:
What are the names of teams from universities that have a below average enrollment?
Additional table information: table: university_basketball

Answer: SELECT t2.team_name FROM university AS t1 JOIN basketball_match AS t2 ON t1.school_id = t2.school_id WHERE enrollment < (SELECT AVG(enrollment) FROM university)


Question:
Which rank has the smallest number of faculty members?
Additional table information: table: activity_1

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


Question:
What is the name of the county with the greatest population?
Additional table information: table: county_public_safety

Answer: SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1


Question:
What are the distinct location names?
Additional table information: table: cre_Theme_park

Answer: SELECT DISTINCT Location_Name FROM LOCATIONS


Question:
For each city, how many branches opened before 2010?
Additional table information: table: shop_membership

Answer: SELECT city, COUNT(*) FROM branch WHERE open_year < 2010 GROUP BY city


Question:
What are the names of ships that have more than one captain?
Additional table information: table: ship_1

Answer: SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id GROUP BY t2.ship_id HAVING COUNT(*) > 1


Question:
Find the type code of the most frequently used policy.
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:
What is the membership level with the most people?
Additional table information: table: shop_membership

Answer: SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the different types of forms?
Additional table information: table: e_government

Answer: SELECT DISTINCT form_type_code FROM forms


Question:
Find the number of tweets in record.
Additional table information: table: twitter_1

Answer: SELECT COUNT(*) FROM tweets


Question:
What are the renting arrears tax ids related to the customer master index whose detail is not 'Schmidt, Kertzmann and Lubowitz'?
Additional table information: table: local_govt_mdm

Answer: SELECT T1.council_tax_id FROM Rent_Arrears AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id JOIN Customer_Master_Index AS T3 ON T3.master_customer_id = T2.master_customer_id WHERE T3.cmi_details <> 'Schmidt ,  Kertzmann and Lubowitz'


Question:
Show each school name, its budgeted amount, and invested amount in year 2002 or after.
Additional table information: table: school_finance

Answer: SELECT T2.school_name, T1.budgeted, T1.invested FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.year >= 2002


Question:
Please show the employee last names that serves no more than 20 customers.
Additional table information: table: chinook_1

Answer: SELECT T1.LastName FROM CUSTOMER AS T1 JOIN EMPLOYEE AS T2 ON T1.SupportRepId = T2.EmployeeId GROUP BY T1.SupportRepId HAVING COUNT(*) <= 20


Question:
Show the season, the player, and the name of the team that players belong to.
Additional table information: table: match_season

Answer: SELECT T1.Season, T1.Player, T2.Name FROM match_season AS T1 JOIN team AS T2 ON T1.Team = T2.Team_id


Question:
How many customers live in Prague city?
Additional table information: table: store_1

Answer: SELECT COUNT(*) FROM customers WHERE city = 'Prague'


Question:
What is the height of the mountain climbined by the climbing who had the most points?
Additional table information: table: climbing

Answer: SELECT T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID = T2.Mountain_ID ORDER BY T1.Points DESC LIMIT 1


Question:
Find the name of companies that do not make DVD drive.
Additional table information: table: manufactory_1

Answer: SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.manufacturer = T2.code WHERE T1.name = 'DVD drive'


Question:
What are the names of countries that have both players with position forward and players with position defender?
Additional table information: table: match_season

Answer: SELECT T1.Country_name FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.Position = 'Forward' INTERSECT SELECT T1.Country_name FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.Position = 'Defender'


Question:
What is the total number of points for all players?
Additional table information: table: sports_competition

Answer: SELECT SUM(Points) FROM player


Question:
Find the names and number of works of the three artists who have produced the most songs.
Additional table information: table: music_1

Answer: SELECT T1.artist_name, COUNT(*) FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name GROUP BY T2.artist_name ORDER BY COUNT(*) DESC LIMIT 3


Question:
For each company, return the company name and the name of the building its office is located in.
Additional table information: table: company_office

Answer: SELECT T3.name, T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id


Question:
What is the name of the customer with the worst credit score?
Additional table information: table: loan_1

Answer: SELECT cust_name FROM customer ORDER BY credit_score NULLS FIRST LIMIT 1


Question:
How many addresses have zip code 197?
Additional table information: table: behavior_monitoring

Answer: SELECT COUNT(*) FROM ADDRESSES WHERE zip_postcode = '197'


Question:
List the order dates of all the bookings.
Additional table information: table: cre_Drama_Workshop_Groups

Answer: SELECT Order_Date FROM BOOKINGS


Question:
How many distinct hometowns did these people have?
Additional table information: table: gymnast

Answer: SELECT COUNT(DISTINCT Hometown) FROM people


Question:
What are the names of all females who are friends with Zach?
Additional table information: table: network_2

Answer: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Zach' AND T1.gender = 'female'


Question:
For each delegate, find the names of the party they are part of.
Additional table information: table: election

Answer: SELECT T1.Delegate, T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID


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

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


Question:
What is the id of every employee who has at least a salary of  100000?
Additional table information: table: flight_1

Answer: SELECT eid FROM Employee WHERE salary > 100000


Question:
Count the number of distinct delegates who are from counties with population above 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:
How many churches have a wedding in year 2016?
Additional table information: table: wedding

Answer: SELECT COUNT(DISTINCT church_id) FROM wedding WHERE YEAR = 2016


Question:
Which countries has the most number of airlines?
Additional table information: table: flight_4

Answer: SELECT country FROM airlines GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1


Question:
Count the number of accounts.
Additional table information: table: small_bank_1

Answer: SELECT COUNT(*) FROM accounts


Question:
Give me the payment Id, the date and the amount for all the payments processed with Visa.
Additional table information: table: insurance_policies

Answer: SELECT Payment_ID, Date_Payment_Made, Amount_Payment FROM Payments WHERE Payment_Method_Code = 'Visa'


Question:
What is the average credit score for customers who have taken a loan?
Additional table information: table: loan_1

Answer: SELECT AVG(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)


Question:
What is the address content of the customer named 'Maudie Kertzmann'?
Additional table information: table: customers_and_addresses

Answer: SELECT t3.address_content FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t1.customer_name = 'Maudie Kertzmann'


Question:
What are the names of musicals who have no actors?
Additional table information: table: musical

Answer: SELECT Name FROM musical WHERE NOT Musical_ID IN (SELECT Musical_ID FROM actor)


Question:
How many professors teach a class with the code ACCT-211?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = 'ACCT-211'


Question:
How many females are in the network?
Additional table information: table: network_2

Answer: SELECT COUNT(*) FROM Person WHERE gender = 'female'


Question:
What is the name of each camera lens and the number of photos taken by it? Order the result by the count of photos.
Additional table information: table: mountain_photos

Answer: SELECT T1.name, COUNT(*) FROM camera_lens AS T1 JOIN photos AS T2 ON T1.id = T2.camera_lens_id GROUP BY T1.id ORDER BY COUNT(*) NULLS FIRST


Question:
What is the starting year of the oldest technicians?
Additional table information: table: machine_repair

Answer: SELECT Starting_Year FROM technician ORDER BY Age DESC LIMIT 1


Question:
What is the code of the school where the accounting department belongs to?
Additional table information: table: college_1

Answer: SELECT school_code FROM department WHERE dept_name = 'Accounting'


Question:
How many distinct characteristic names does the product 'cumin' have?
Additional table information: table: products_gen_characteristics

Answer: SELECT COUNT(DISTINCT 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 WHERE t1.product_name = 'sesame'


Question:
What is the number of distinct teams that suffer elimination?
Additional table information: table: wrestler

Answer: SELECT COUNT(DISTINCT team) FROM elimination


Question:
What are the codes of the locations with at least three documents?
Additional table information: table: cre_Doc_Tracking_DB

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


Question:
Which building has most faculty members?
Additional table information: table: activity_1

Answer: SELECT building FROM Faculty GROUP BY building ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the first names of professors who are teaching more than one class.
Additional table information: table: college_1

Answer: SELECT T2.emp_fname FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num GROUP BY T1.prof_num HAVING COUNT(*) > 1


Question:
Show party names and the number of events for each party.
Additional table information: table: party_people

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


Question:
Count the number of different account types.
Additional table information: table: loan_1

Answer: SELECT COUNT(DISTINCT acc_type) FROM customer


Question:
How many days had both mean humidity above 50 and mean visibility above 8?
Additional table information: table: bike_1

Answer: SELECT COUNT(*) FROM weather WHERE mean_humidity > 50 AND mean_visibility_miles > 8


Question:
What are the type codes and descriptions of each budget type?
Additional table information: table: cre_Docs_and_Epenses

Answer: SELECT budget_type_code, budget_type_description FROM Ref_budget_codes


Question:
What is the name of 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:
Find the minimum salary for the departments whose average salary is above the average payment of all instructors.
Additional table information: table: college_2

Answer: SELECT MIN(salary), dept_name FROM instructor GROUP BY dept_name HAVING AVG(salary) > (SELECT AVG(salary) FROM instructor)


Question:
Return the hosts of competitions for which the theme is not Aliens?
Additional table information: table: farm

Answer: SELECT Hosts FROM farm_competition WHERE Theme <> 'Aliens'


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

Answer: SELECT LOCATION FROM perpetrator ORDER BY Killed DESC LIMIT 1


Question:
when is the hire date for those employees whose first name does not containing the letter M?
Additional table information: table: hr_1

Answer: SELECT hire_date FROM employees WHERE NOT first_name LIKE '%M%'


Question:
Find all the players' first name and last name who have empty death record.
Additional table information: table: baseball_1

Answer: SELECT name_first, name_last FROM player WHERE death_year = ''


Question:
What is the average number of working horses of farms with more than 5000 total number of horses?
Additional table information: table: farm

Answer: SELECT AVG(Working_Horses) FROM farm WHERE Total_Horses > 5000


Question:
Show the names of members and the dates of performances they attended in descending order of attendance of the performances.
Additional table information: table: performance_attendance

Answer: SELECT T2.Name, T3.Date FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID ORDER BY T3.Attendance DESC


Question:
What are the maximum price and score of wines for each year?
Additional table information: table: wine_1

Answer: SELECT MAX(Price), MAX(Score), YEAR FROM WINE GROUP BY YEAR


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

Answer: SELECT COUNT(DISTINCT card_type_code) FROM Customers_Cards


Question:
How many airports' names have the word Interanation in them?
Additional table information: table: flight_4

Answer: SELECT COUNT(*) FROM airports WHERE name LIKE '%International%'


Question:
What is the average and maximum damage in millions for storms that had a max speed over 1000?
Additional table information: table: storm_record

Answer: SELECT AVG(damage_millions_USD), MAX(damage_millions_USD) FROM storm WHERE max_speed > 1000


Question:
Find the average order quantity per order.
Additional table information: table: customers_and_addresses

Answer: SELECT AVG(order_quantity) FROM order_items


Question:
Return the names of cities, ordered alphabetically.
Additional table information: table: county_public_safety

Answer: SELECT Name FROM city ORDER BY Name ASC NULLS FIRST


Question:
List the distinct positions of pilots older than 30.
Additional table information: table: pilot_record

Answer: SELECT DISTINCT POSITION FROM pilot WHERE Age > 30


Question:
Find the personal name, family name, and author ID of the course author that teaches the most courses.
Additional table information: table: e_learning

Answer: SELECT T1.personal_name, T1.family_name, T2.author_id FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id GROUP BY T2.author_id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the average access counts of documents with functional area 'Acknowledgement'.
Additional table information: table: document_management

Answer: SELECT AVG(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code = t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code = t3.functional_area_code WHERE t3.functional_area_description = 'Acknowledgement'


Question:
Which patients made more than one appointment? Tell me the name and phone number of these patients.
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:
How many departments are in each school?
Additional table information: table: college_1

Answer: SELECT COUNT(DISTINCT dept_name), school_code FROM department GROUP BY school_code


Question:
How old is the doctor named Zach?
Additional table information: table: network_2

Answer: SELECT age FROM Person WHERE job = 'doctor' AND name = 'Zach'


Question:
Give the names and locations of all wrestlers.
Additional table information: table: wrestler

Answer: SELECT Name, LOCATION FROM wrestler


Question:
What is the total revenue of companies started by founder?
Additional table information: table: manufactory_1

Answer: SELECT SUM(revenue), founder FROM manufacturers GROUP BY founder


Question:
What is the average enrollment of schools?
Additional table information: table: school_player

Answer: SELECT AVG(Enrollment) FROM school


Question:
What is the id, name and IATA code of the airport that had most number of flights?
Additional table information: table: flight_company

Answer: SELECT T1.id, T1.name, T1.IATA FROM airport AS T1 JOIN flight AS T2 ON T1.id = T2.airport_id GROUP BY T2.id ORDER BY COUNT(*) DESC LIMIT 1


Question:
What are the subject ID, subject name, and the number of available courses for each subject?
Additional table information: table: e_learning

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


Question:
What are the names and addressed of customers who have both New and Pending orders?
Additional table information: table: department_store

Answer: SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'New' INTERSECT SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Pending'


Question:
What are all distinct country for artists?
Additional table information: table: theme_gallery

Answer: SELECT DISTINCT country FROM artist


Question:
What are the names of all the players who received a yes during tryouts, and also what are the names of their colleges?
Additional table information: table: soccer_2

Answer: SELECT T1.pName, T2.cName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes'


Question:
How many courses does the student with id 171 actually attend?
Additional table information: table: student_assessment

Answer: SELECT COUNT(*) FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T2.student_id = 171


Question:
What are the publishers who have published a book in both 1989 and 1990?
Additional table information: table: culture_company

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


Question:
What nurses are on call with block floor 1 and block code 1? Tell me their names.
Additional table information: table: hospital_1

Answer: SELECT nurse FROM on_call WHERE blockfloor = 1 AND blockcode = 1