question
stringlengths
63
269
answer
stringlengths
18
557
Show ids for all students who live in CHI. Additional table information: table: game_1
SELECT StuID FROM Student WHERE city_code = 'CHI'
Find the last names of students with major 50. Additional table information: table: voter_2
SELECT LName FROM STUDENT WHERE Major = 50
What is the unit of measurement of product named 'cumin'? Additional table information: table: products_gen_characteristics
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'
Find the component amounts and names of all furnitures that have more than 10 components. Additional table information: table: manufacturer
SELECT Num_of_Component, name FROM furniture WHERE Num_of_Component > 10
What are the details of the project with no outcomes? Additional table information: table: tracking_grants_for_research
SELECT project_details FROM Projects WHERE NOT project_id IN (SELECT project_id FROM Project_outcomes)
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
SELECT first_name, last_name, hire_date FROM employees WHERE department_id = (SELECT department_id FROM employees WHERE first_name = 'Clara')
Which of the mill names contains the french word 'Moulin'? Additional table information: table: architecture
SELECT name FROM mill WHERE name LIKE '%Moulin%'
What are the first names of all students in Smith Hall? Additional table information: table: dorm_1
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'
List the types of competition that have at most five competitions of that type. Additional table information: table: sports_competition
SELECT Competition_type FROM competition GROUP BY Competition_type HAVING COUNT(*) <= 5
list names of all departments ordered by their names. Additional table information: table: college_1
SELECT dept_name FROM department ORDER BY dept_name NULLS FIRST
Please show the employee first names and ids of employees who serve at least 10 customers. Additional table information: table: chinook_1
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
What are the names of the districts that have both mall and village store style shops? Additional table information: table: store_product
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'
List the open date of open year of the shop named 'Apple'. Additional table information: table: device
SELECT Open_Date, Open_Year FROM shop WHERE Shop_Name = 'Apple'
Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25. Additional table information: table: tracking_orders
SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < '1989-09-03' OR invoice_date > '2007-12-25'
Find the names of users who did not leave any review. Additional table information: table: epinions_1
SELECT name FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)
Provide the full names of employees earning more than the employee with id 163. Additional table information: table: hr_1
SELECT first_name, last_name FROM employees WHERE salary > (SELECT salary FROM employees WHERE employee_id = 163)
Return the text of tweets about the topic 'intern'. Additional table information: table: twitter_1
SELECT text FROM tweets WHERE text LIKE '%intern%'
Find the name of customers who are living in Colorado? Additional table information: table: customers_and_addresses
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'
Return the result that is most frequent at music festivals. Additional table information: table: music_4
SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1
Find the number of songs in all the studio albums. Additional table information: table: music_2
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'
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
SELECT name, salary FROM instructor WHERE salary < (SELECT AVG(salary) FROM instructor WHERE dept_name = 'Physics')
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
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'
List the name of all products along with the number of complaints that they have received. Additional table information: table: customer_complaints
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
Return the prices of wines produced before 2010. Additional table information: table: wine_1
SELECT Price FROM WINE WHERE YEAR < 2010
Show different carriers of phones together with the number of phones with each carrier. Additional table information: table: phone_market
SELECT Carrier, COUNT(*) FROM phone GROUP BY Carrier
Which customers use 'Cash' for payment method? Return the customer names. Additional table information: table: customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method = 'Cash'
Find the number of scientists who are not assigned to any project. Additional table information: table: scientist_1
SELECT COUNT(*) FROM scientists WHERE NOT ssn IN (SELECT scientist FROM AssignedTo)
Find the names and number of works of all artists who have at least one English songs. Additional table information: table: music_1
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
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
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
What is the total balance of savings accounts not belonging to someone with the name Brown? Additional table information: table: small_bank_1
SELECT SUM(T2.balance) FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T1.name <> 'Brown'
Find the types of documents with more than 4 documents. Additional table information: table: document_management
SELECT document_type_code FROM documents GROUP BY document_type_code HAVING COUNT(*) > 4
Find the first names of all the authors ordered in alphabetical order. Additional table information: table: icfp_1
SELECT fname FROM authors ORDER BY fname NULLS FIRST
How many people whose age is greater 30 and job is engineer? Additional table information: table: network_2
SELECT COUNT(*) FROM Person WHERE age > 30 AND job = 'engineer'
What is the description of the product category with the code 'Spices'? Additional table information: table: products_gen_characteristics
SELECT product_category_description FROM ref_product_categories WHERE product_category_code = 'Spices'
What are the names of every person who has a friend over 40 and under 30? Additional table information: table: network_2
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)
What is the total amount of payment? Additional table information: table: insurance_policies
SELECT SUM(Amount_Payment) FROM Payments
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
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'
Find the name of dorms which have both TV Lounge and Study Room as amenities. Additional table information: table: dorm_1
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'
How many different last names do the actors and actresses have? Additional table information: table: sakila_1
SELECT COUNT(DISTINCT last_name) FROM actor
Show the first name and last name for the customer with account name 900. Additional table information: table: customers_and_invoices
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'
For each station, find its latitude and the minimum duration of trips that ended at the station. Additional table information: table: bike_1
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
Return the number of customers who have at least one order with 'Cancelled' status. Additional table information: table: customers_and_addresses
SELECT COUNT(DISTINCT customer_id) FROM customer_orders WHERE order_status = 'Cancelled'
What are the names of the directors who made exactly one movie? Additional table information: table: movie_1
SELECT director FROM Movie GROUP BY director HAVING COUNT(*) = 1
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
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
Find the number of employees whose title is IT Staff from each city? Additional table information: table: store_1
SELECT COUNT(*), city FROM employees WHERE title = 'IT Staff' GROUP BY city
What are the average prices of hotels grouped by their pet policy. Additional table information: table: cre_Theme_park
SELECT pets_allowed_yn, AVG(price_range) FROM HOTELS GROUP BY pets_allowed_yn
Find the salary and manager number for those employees who is working under a manager. Additional table information: table: hr_1
SELECT salary, manager_id FROM employees WHERE manager_id <> 'null'
What are the three most costly procedures? Additional table information: table: hospital_1
SELECT name FROM procedures ORDER BY cost NULLS FIRST LIMIT 3
Find the the grape whose white color grapes are used to produce wines with scores higher than 90. Additional table information: table: wine_1
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
How many donors have endowment for school named 'Glenn'? Additional table information: table: school_finance
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'
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
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%'
Count the number of budget codes. Additional table information: table: cre_Docs_and_Epenses
SELECT COUNT(*) FROM Ref_budget_codes
List all document type codes and document type names. Additional table information: table: cre_Doc_Tracking_DB
SELECT document_type_code, document_type_name FROM Ref_document_types
What are the names of all the scientists in alphabetical order? Additional table information: table: scientist_1
SELECT name FROM scientists ORDER BY name NULLS FIRST
Find all types of store and number of them. Additional table information: table: store_product
SELECT TYPE, COUNT(*) FROM store GROUP BY TYPE
what are the name of players who get more than the average points. Additional table information: table: sports_competition
SELECT name FROM player WHERE points > (SELECT AVG(points) FROM player)
How many milliseconds long is Fast As a Shark? Additional table information: table: store_1
SELECT milliseconds FROM tracks WHERE name = 'Fast As a Shark'
Find the names of rooms that have been reserved for more than 60 times. Additional table information: table: inn_1
SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room HAVING COUNT(*) > 60
Give the title and credits for the course that is taught in the classroom with the greatest 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)
What is the id of the patient who stayed in room 111 most recently? Additional table information: table: hospital_1
SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1
How many addresses are in the district of California? Additional table information: table: sakila_1
SELECT COUNT(*) FROM address WHERE district = 'California'
Show the ids and names of all documents. Additional table information: table: cre_Docs_and_Epenses
SELECT document_id, document_name FROM Documents
Which artist has the most albums? Additional table information: table: chinook_1
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
What is the title, phone and hire date of Nancy Edwards? Additional table information: table: store_1
SELECT title, phone, hire_date FROM employees WHERE first_name = 'Nancy' AND last_name = 'Edwards'
What is the average weight of all players? Additional table information: table: soccer_1
SELECT AVG(weight) FROM Player
What is the marketing region code that has the most drama workshop groups? Additional table information: table: cre_Drama_Workshop_Groups
SELECT Marketing_Region_Code FROM Drama_Workshop_Groups GROUP BY Marketing_Region_Code ORDER BY COUNT(*) DESC LIMIT 1
What are the delegate and committee information for each election record? Additional table information: table: election
SELECT Delegate, Committee FROM election
What are the prices of products that have never gotten a complaint? Additional table information: table: customer_complaints
SELECT product_price FROM products WHERE NOT product_id IN (SELECT product_id FROM complaints)
Return the detail of the location named 'UK Gallery'. Additional table information: table: cre_Theme_park
SELECT Other_Details FROM LOCATIONS WHERE Location_Name = 'UK Gallery'
Give the country id and corresponding count of cities in each country. Additional table information: table: hr_1
SELECT country_id, COUNT(*) FROM locations GROUP BY country_id
Find the average checking balance. Additional table information: table: small_bank_1
SELECT AVG(balance) FROM checking
Show the station name with greatest number of trains. Additional table information: table: train_station
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
What are the course names, ordered by credits? Additional table information: table: college_3
SELECT CName FROM COURSE ORDER BY Credits NULLS FIRST
Find the name of the person who has friends with age above 40 and under age 30? Additional table information: table: network_2
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)
Find the name of the ships that have more than one captain. Additional table information: table: ship_1
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
Count the total number of policies used by the customer named 'Dayana Robel'. Additional table information: table: insurance_fnol
SELECT COUNT(*) FROM customers AS t1 JOIN customers_policies AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = 'Dayana Robel'
Find the number of airports whose name contain the word 'International'. Additional table information: table: flight_4
SELECT COUNT(*) FROM airports WHERE name LIKE '%International%'
Find the name of instructors who are advising more than one student. Additional table information: table: college_2
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
For each payment method, return how many customers use it. Additional table information: table: department_store
SELECT payment_method_code, COUNT(*) FROM customers GROUP BY payment_method_code
List all the contact channel codes that were used less than 5 times. Additional table information: table: customers_and_addresses
SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING COUNT(customer_id) < 5
What are the number of international and domestic passengers of the airport named London 'Heathrow'? Additional table information: table: aircraft
SELECT International_Passengers, Domestic_Passengers FROM airport WHERE Airport_Name = 'London Heathrow'
What is the first and last name of the employee who reports to Nancy Edwards? Additional table information: table: store_1
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'
How many different users wrote some reviews? Additional table information: table: epinions_1
SELECT COUNT(DISTINCT u_id) FROM review
What are the member names and hometowns of those who registered at a branch in 2016? Additional table information: table: shop_membership
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
Find all the zip codes in which the max dew point have never reached 70. Additional table information: table: bike_1
SELECT DISTINCT zip_code FROM weather EXCEPT SELECT DISTINCT zip_code FROM weather WHERE max_dew_point_f >= 70
What are the the songs in volumes, listed in ascending order? Additional table information: table: music_4
SELECT Song FROM volume ORDER BY Song NULLS FIRST
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
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)
Give id of the instructor who advises students in the History department. Additional table information: table: college_2
SELECT i_id FROM advisor AS T1 JOIN student AS T2 ON T1.s_id = T2.id WHERE T2.dept_name = 'History'
What are the names of all reviewers that have given 3 or 4 stars for reviews? Additional table information: table: movie_1
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
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born. Additional table information: table: department_management
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'
Find all the songs that do not have a lead vocal. Additional table information: table: music_2
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'
What is the customer first, last name and id with least number of accounts. Additional table information: table: customers_card_transactions
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
Count the number of wines produced at Robert Biale winery. Additional table information: table: wine_1
SELECT COUNT(*) FROM WINE WHERE Winery = 'Robert Biale'
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
SELECT location_code, date_in_location_from, date_in_locaton_to FROM Document_locations
Find the first names of professors who are not playing Canoeing or Kayaking. Additional table information: table: activity_1
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'
What is the date of birth of every customer whose status code is 'Good Customer'? Additional table information: table: driving_school
SELECT date_of_birth FROM Customers WHERE customer_status_code = 'Good Customer'
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
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
What are the songs in album 'A Kiss Before You Go: Live in Hamburg'? Additional table information: table: music_2
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'
What are the names and urls of images, sorted alphabetically? Additional table information: table: document_management
SELECT image_name, image_url FROM images ORDER BY image_name NULLS FIRST
How many different jobs are listed? Additional table information: table: network_2
SELECT COUNT(DISTINCT job) FROM Person