question
stringlengths
63
269
answer
stringlengths
18
557
What is the name of the department with the fewest members? Additional table information: table: college_3
SELECT T1.DName FROM DEPARTMENT AS T1 JOIN MEMBER_OF AS T2 ON T1.DNO = T2.DNO GROUP BY T2.DNO ORDER BY COUNT(*) ASC NULLS FIRST LIMIT 1
How many appelations are in Napa Country? Additional table information: table: wine_1
SELECT COUNT(*) FROM APPELLATIONS WHERE County = 'Napa'
Show all the information about election. Additional table information: table: election
SELECT * FROM election
What is the document type name for the document with name 'How to read a book'? Additional table information: table: cre_Doc_Tracking_DB
SELECT T2.document_type_name FROM All_documents AS T1 JOIN Ref_document_types AS T2 ON T1.document_type_code = T2.document_type_code WHERE T1.document_name = 'How to read a book'
What are the details for statements with the details 'Private Project', and what are the names of the corresponding documents? Additional table information: table: cre_Docs_and_Epenses
SELECT T1.statement_details, T2.document_name FROM Statements AS T1 JOIN Documents AS T2 ON T1.statement_id = T2.document_id WHERE T1.statement_details = 'Private Project'
What are the customer id and name corresponding to accounts with a checking balance less than the largest checking balance? Additional table information: table: small_bank_1
SELECT T1.custid, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT MAX(balance) FROM checking)
What is the mean longitude for all stations that have never had more than 10 bikes available? Additional table information: table: bike_1
SELECT AVG(long) FROM station WHERE NOT id IN (SELECT station_id FROM status GROUP BY station_id HAVING MAX(bikes_available) > 10)
Return reviewer name, movie title, stars, and ratingDate. And sort the data first by reviewer name, then by movie title, and lastly by number of stars. Additional table information: table: movie_1
SELECT T3.name, T2.title, T1.stars, T1.ratingDate FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID ORDER BY T3.name NULLS FIRST, T2.title NULLS FIRST, T1.stars NULLS FIRST
What are the names of all the aircrafts associated with London Gatwick airport? Additional table information: table: aircraft
SELECT T1.Aircraft 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 T3.Airport_Name = 'London Gatwick'
How many different genders are there in the dorms? Additional table information: table: dorm_1
SELECT COUNT(DISTINCT gender) FROM dorm
Who are the players from Indonesia? Additional table information: table: match_season
SELECT T2.Player FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T1.Country_name = 'Indonesia'
How many games are free of injury accidents? Additional table information: table: game_injury
SELECT COUNT(*) FROM game WHERE NOT id IN (SELECT game_id FROM injury_accident)
Show the id and name of the aircraft with the maximum distance. Additional table information: table: flight_1
SELECT aid, name FROM Aircraft ORDER BY distance DESC LIMIT 1
Show all customer ids and the number of accounts for each customer. Additional table information: table: customers_card_transactions
SELECT customer_id, COUNT(*) FROM Accounts GROUP BY customer_id
Return the first names and last names of employees who earn more than 30000 in salary. Additional table information: table: company_1
SELECT fname, lname FROM employee WHERE salary > 30000
What is the 3 most common cloud cover rates in the region of zip code 94107? Additional table information: table: bike_1
SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT(*) DESC LIMIT 3
How many products are there? Additional table information: table: products_gen_characteristics
SELECT COUNT(*) FROM products
What are the first and last names of the employee with the earliest date of birth? Additional table information: table: college_1
SELECT emp_fname, emp_lname FROM employee ORDER BY emp_dob NULLS FIRST LIMIT 1
What is the name, type, and flag of the ship that was built in the most recent year? Additional table information: table: ship_1
SELECT name, TYPE, flag FROM ship ORDER BY built_year DESC LIMIT 1
How many students have had at least one 'B' grade? Additional table information: table: college_3
SELECT COUNT(DISTINCT StuID) FROM ENROLLED_IN WHERE Grade = 'B'
Give the hometowns from which two or more gymnasts are from. Additional table information: table: gymnast
SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown HAVING COUNT(*) >= 2
List all of the player ids with a height of at least 180cm and an overall rating higher than 85. Additional table information: table: soccer_1
SELECT player_api_id FROM Player WHERE height >= 180 INTERSECT SELECT player_api_id FROM Player_Attributes WHERE overall_rating > 85
Which locations contains both shops that opened after the year 2012 and shops that opened before 2008? Additional table information: table: device
SELECT LOCATION FROM shop WHERE Open_Year > 2012 INTERSECT SELECT LOCATION FROM shop WHERE Open_Year < 2008
How many type of jobs do they have? Additional table information: table: network_2
SELECT COUNT(DISTINCT job) FROM Person
What is the role of the employee named Koby? Additional table information: table: cre_Doc_Control_Systems
SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = 'Koby'
Advisor 1121 has how many students? Additional table information: table: restaurant_1
SELECT COUNT(*) FROM Student WHERE Advisor = 1121
find the name of all departments that do actually have one or more employees assigned to them. Additional table information: table: hr_1
SELECT DISTINCT T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id
How many followers does each user have? Additional table information: table: twitter_1
SELECT COUNT(*) FROM follows
Show the ids of all the faculty members who participate in an activity and advise a student. Additional table information: table: activity_1
SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student
What is the velocity of the pilot named 'Thompson'? Additional table information: table: flight_company
SELECT AVG(velocity) FROM flight WHERE pilot = 'Thompson'
What are the different reviewer names, movie titles, and stars for every rating where the reviewer had the same name as the director? Additional table information: table: movie_1
SELECT DISTINCT T3.name, T2.title, T1.stars FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.director = T3.name
At which restaurant did the students spend the least amount of time? List restaurant and the time students spent on in total. Additional table information: table: restaurant_1
SELECT Restaurant.ResName, SUM(Visits_Restaurant.Spent) FROM Visits_Restaurant JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID GROUP BY Restaurant.ResID ORDER BY SUM(Visits_Restaurant.Spent) ASC NULLS FIRST LIMIT 1
Find the names of the trains that do not pass any station located in London. Additional table information: table: train_station
SELECT T2.name FROM train_station AS T1 JOIN train AS T2 ON T1.train_id = T2.train_id WHERE NOT T1.station_id IN (SELECT T4.station_id FROM train_station AS T3 JOIN station AS T4 ON T3.station_id = T4.station_id WHERE t4.location = 'London')
What is the name of the youngest captain? Additional table information: table: ship_1
SELECT name FROM captain ORDER BY age NULLS FIRST LIMIT 1
Show the names of all the activities Mark Giuliano participates in. Additional table information: table: activity_1
SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN Activity AS T3 ON T3.actid = T2.actid WHERE T1.fname = 'Mark' AND T1.lname = 'Giuliano'
Find the first name and office of the professor who is in the history department and has a Ph.D. degree. Additional table information: table: college_1
SELECT T1.emp_fname, T2.prof_office FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num JOIN department AS T3 ON T3.dept_code = T2.dept_code WHERE T3.dept_name = 'History' AND T2.prof_high_degree = 'Ph.D.'
What are the names of the airports in the city of Goroka? Additional table information: table: flight_4
SELECT name FROM airports WHERE city = 'Goroka'
Find the name, address, number of students in the departments that have the top 3 highest number of students. Additional table information: table: college_1
SELECT T2.dept_name, T2.dept_address, COUNT(*) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY COUNT(*) DESC LIMIT 3
What is the id of the appointment that started most recently? Additional table information: table: hospital_1
SELECT appointmentid FROM appointment ORDER BY START DESC LIMIT 1
List the first names of all the students in room 107. Additional table information: table: student_1
SELECT DISTINCT firstname FROM list WHERE classroom = 107
Show all the distinct president votes made on 08/30/2015. Additional table information: table: voter_2
SELECT DISTINCT PRESIDENT_Vote FROM VOTING_RECORD WHERE Registration_Date = '08/30/2015'
Find the name of the product that has the smallest capacity. Additional table information: table: product_catalog
SELECT catalog_entry_name FROM catalog_contents ORDER BY capacity ASC NULLS FIRST LIMIT 1
What are the descriptions and names of the courses that have student enrollment bigger than 2? Additional table information: table: e_learning
SELECT T1.course_description, T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) > 2
List the authors who do not have submission to any workshop. Additional table information: table: workshop_paper
SELECT Author FROM submission WHERE NOT Submission_ID IN (SELECT Submission_ID FROM acceptance)
Find the total population of the districts where the area is bigger than the average city area. Additional table information: table: store_product
SELECT SUM(city_population) FROM district WHERE city_area > (SELECT AVG(city_area) FROM district)
What is the average age for each city and what are those cities? Additional table information: table: dorm_1
SELECT AVG(age), city_code FROM student GROUP BY city_code
What is the total and maximum duration for all trips with the bike id 636? Additional table information: table: bike_1
SELECT SUM(duration), MAX(duration) FROM trip WHERE bike_id = 636
What is the name and description for document type code RV? Additional table information: table: cre_Doc_Tracking_DB
SELECT document_type_name, document_type_description FROM Ref_document_types WHERE document_type_code = 'RV'
What are the job ids and dates of hire for employees hired after November 5th, 2007 and before July 5th, 2009? Additional table information: table: hr_1
SELECT job_id, hire_date FROM employees WHERE hire_date BETWEEN '2007-11-05' AND '2009-07-05'
Find the number of rooms with a king bed. Additional table information: table: inn_1
SELECT COUNT(*) FROM Rooms WHERE bedType = 'King'
List every album ordered by album title in ascending order. Additional table information: table: store_1
SELECT title FROM albums ORDER BY title NULLS FIRST
For each distinct test result, find the number of students who got the result. Additional table information: table: e_learning
SELECT test_result, COUNT(*) FROM Student_Tests_Taken GROUP BY test_result ORDER BY COUNT(*) DESC
What are the names of the physician who prescribed the highest dose? Additional table information: table: hospital_1
SELECT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician ORDER BY T2.dose DESC LIMIT 1
What is the number of faculty at Long Beach State University in 2002? Additional table information: table: csu_1
SELECT faculty FROM faculty AS T1 JOIN campuses AS T2 ON T1.campus = T2.id WHERE T1.year = 2002 AND T2.campus = 'Long Beach State University'
For each phone, show its names and total number of stocks. Additional table information: table: phone_market
SELECT T2.Name, SUM(T1.Num_of_stock) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name
What is the first name and the last name of the customer who made the earliest rental? Additional table information: table: sakila_1
SELECT T1.first_name, T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC NULLS FIRST LIMIT 1
How many drama workshop groups are there in each city? Return both the city and the count. Additional table information: table: cre_Drama_Workshop_Groups
SELECT T1.City_Town, COUNT(*) FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID GROUP BY T1.City_Town
Find the names of stadiums which have never had any event. Additional table information: table: swimming
SELECT name FROM stadium WHERE NOT id IN (SELECT stadium_id FROM event)
What are the names of the scientists, and how many projects are each of them working on? Additional table information: table: scientist_1
SELECT COUNT(*), T1.name FROM scientists AS T1 JOIN assignedto AS T2 ON T1.ssn = T2.scientist GROUP BY T1.name
Sort all the industries in descending order of the count of companies in each industry Additional table information: table: company_office
SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC
How many customer cards are there? Additional table information: table: customers_card_transactions
SELECT COUNT(*) FROM Customers_cards
Find the number of students who is older than 20 in each dorm. Additional table information: table: dorm_1
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
How many allergies have type animal? Additional table information: table: allergy_1
SELECT COUNT(*) FROM Allergy_type WHERE allergytype = 'animal'
What campuses opened between 1935 and 1939? Additional table information: table: csu_1
SELECT campus FROM campuses WHERE YEAR >= 1935 AND YEAR <= 1939
What is the location shared by most counties? Additional table information: table: county_public_safety
SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1
For each city, list their names in decreasing order by their highest station latitude. Additional table information: table: bike_1
SELECT city FROM station GROUP BY city ORDER BY MAX(lat) DESC
Show the name, home city, and age for all drivers. Additional table information: table: school_bus
SELECT name, home_city, age FROM driver
What is the total enrollment number of all colleges? Additional table information: table: soccer_2
SELECT SUM(enr) FROM College
Find all manufacturers' names and their headquarters, sorted by the ones with highest revenue first. Additional table information: table: manufactory_1
SELECT name, headquarter FROM manufacturers ORDER BY revenue DESC
What are the ids and first names of customers who do not hold a credit card? Additional table information: table: customers_card_transactions
SELECT customer_id, customer_first_name FROM Customers EXCEPT SELECT T1.customer_id, T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = 'Credit'
What is the title and credits of the course that is taught in the largest classroom (with the highest capacity)? Additional table information: table: college_2
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)
How many different payment methods are there? Additional table information: table: customer_deliveries
SELECT COUNT(DISTINCT payment_method) FROM customers
Show the id, the date of account opened, the account name, and other account detail for all accounts. Additional table information: table: customers_and_invoices
SELECT account_id, date_account_opened, account_name, other_account_details FROM Accounts
Show the name of colleges that have at least two players. Additional table information: table: match_season
SELECT College FROM match_season GROUP BY College HAVING COUNT(*) >= 2
Which city does the student whose last name is 'Kim' live in? Additional table information: table: allergy_1
SELECT city_code FROM Student WHERE LName = 'Kim'
Find the name and partition id for users who tweeted less than twice. Additional table information: table: twitter_1
SELECT T1.name, T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) < 2
What are the teams of the players, sorted in ascending alphabetical order? Additional table information: table: school_player
SELECT Team FROM player ORDER BY Team ASC NULLS FIRST
List the race class with at least two races. Additional table information: table: race_track
SELECT CLASS FROM race GROUP BY CLASS HAVING COUNT(*) >= 2
Among all the claims, which claims have a claimed amount larger than the average? List the date the claim was made and the date it was settled. Additional table information: table: insurance_policies
SELECT Date_Claim_Made, Date_Claim_Settled FROM Claims WHERE Amount_Claimed > (SELECT AVG(Amount_Claimed) FROM Claims)
How many acting statuses are there? Additional table information: table: department_management
SELECT COUNT(DISTINCT temporary_acting) FROM management
What are the average rating and resolution of songs that are in Bangla? Additional table information: table: music_1
SELECT AVG(rating), AVG(resolution) FROM song WHERE languages = 'bangla'
Find names of all students who took some course and the course description. Additional table information: table: college_1
SELECT T1.stu_fname, T1.stu_lname, T4.crs_description 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 JOIN course AS T4 ON T3.crs_code = T4.crs_code
List all the names of schools with an endowment amount smaller than or equal to 10. Additional table information: table: school_finance
SELECT T2.school_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id GROUP BY T1.school_id HAVING SUM(T1.amount) <= 10
Find the phone number and email address of customer 'Harold'. Additional table information: table: cre_Drama_Workshop_Groups
SELECT Customer_Phone, Customer_Email_Address FROM CUSTOMERS WHERE Customer_Name = 'Harold'
What is the customer id, first and last name with most number of accounts. Additional table information: table: customers_and_invoices
SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1
Which game type has least number of games? Additional table information: table: game_1
SELECT gtype FROM Video_games GROUP BY gtype ORDER BY COUNT(*) NULLS FIRST LIMIT 1
What is the number of colleges with a student population greater than 15000? Additional table information: table: soccer_2
SELECT COUNT(*) FROM College WHERE enr > 15000
Show the players and the years played. Additional table information: table: match_season
SELECT Player, Years_Played FROM player
Show the titles of books in descending order of publication price. Additional table information: table: book_2
SELECT T1.Title FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID ORDER BY T2.Price DESC
Which department has the largest number of employees? Additional table information: table: hospital_1
SELECT name FROM department GROUP BY departmentID ORDER BY COUNT(departmentID) DESC LIMIT 1
How many students play sports? Additional table information: table: game_1
SELECT COUNT(DISTINCT StuID) FROM Sportsinfo
How many girl students who are younger than 25? Additional table information: table: dorm_1
SELECT COUNT(*) FROM student WHERE sex = 'F' AND age < 25
What are the total account balances for each customer from Utah or Texas? Additional table information: table: loan_1
SELECT SUM(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
Which origin has most number of flights? Additional table information: table: flight_1
SELECT origin FROM Flight GROUP BY origin ORDER BY COUNT(*) DESC LIMIT 1
What are the names of the directors who created a movie with a 5 star rating, and what was the name of those movies? Additional table information: table: movie_1
SELECT T1.director, T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5
What are the names of the dorm with the largest capacity? Additional table information: table: dorm_1
SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
Show the ids and details of the investors who have at least two transactions with type code 'SALE'. Additional table information: table: tracking_share_transactions
SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = 'SALE' GROUP BY T2.investor_id HAVING COUNT(*) >= 2
What are all the distinct last names of all the engineers? Additional table information: table: assets_maintenance
SELECT DISTINCT last_name FROM Maintenance_Engineers
Show the station name and number of trains in each station. Additional table information: table: train_station
SELECT T2.name, COUNT(*) FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id
Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id. Additional table information: table: sakila_1
SELECT T1.first_name, T1.last_name, T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY SUM(amount) ASC NULLS FIRST LIMIT 1