database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
student_assessment
SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id JOIN students AS T3 ON T2.person_id = T3.student_id
Find distinct cities of address of students?
student_assessment
SELECT student_id FROM student_course_registrations UNION SELECT student_id FROM student_course_attendance
What are the id of students who registered courses or attended courses?
student_assessment
SELECT course_id FROM student_course_registrations WHERE student_id = 121 UNION SELECT course_id FROM student_course_attendance WHERE student_id = 121
Find the id of courses which are registered or attended by student whose id is 121?
student_assessment
SELECT * FROM student_course_registrations WHERE student_id NOT IN (SELECT student_id FROM student_course_attendance)
What are all info of students who registered courses but not attended courses?
student_assessment
SELECT T2.student_id FROM courses AS T1 JOIN student_course_registrations AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "statistics" ORDER BY T2.registration_date
List the id of students who registered course statistics in the order of registration date.
wrestler
SELECT Name FROM wrestler ORDER BY Days_held ASC LIMIT 1
What is the name of the wrestler with the fewest days held?
wrestler
SELECT T2.Name , T1.Team FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC
List the names of wrestlers and the teams in elimination in descending order of days held.
wrestler
SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID ORDER BY T2.Days_held DESC LIMIT 1
List the time of elimination of the wrestlers with largest days held.
wrestler
SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID WHERE T2.Days_held > 50
Show times of elimination of wrestlers with days held more than 50.
wrestler
SELECT Team FROM elimination GROUP BY Team HAVING COUNT(*) > 3
Show teams that have suffered more than three eliminations.
wrestler
SELECT Reign FROM wrestler GROUP BY Reign ORDER BY COUNT(*) DESC LIMIT 1
Please show the most common reigns of wrestlers.
wrestler
SELECT LOCATION FROM wrestler GROUP BY LOCATION HAVING COUNT(*) > 2
List the locations that are shared by more than two wrestlers.
wrestler
SELECT Name FROM wrestler WHERE Wrestler_ID NOT IN (SELECT Wrestler_ID FROM elimination)
List the names of wrestlers that have not been eliminated.
wrestler
SELECT Team FROM Elimination WHERE Eliminated_By = "Orton" INTERSECT SELECT Team FROM Elimination WHERE Eliminated_By = "Benjamin"
Show the teams that have both wrestlers eliminated by "Orton" and wrestlers eliminated by "Benjamin".
local_govt_and_lot
SELECT T1.property_id , count(*) FROM properties AS T1 JOIN residents AS T2 ON T1.property_id = T2.property_id GROUP BY T1.property_id
How many residents does each property have? List property id and resident count.
local_govt_and_lot
SELECT DISTINCT T1.service_type_code FROM services AS T1 JOIN organizations AS T2 ON T1.organization_id = T2.organization_id WHERE T2.organization_details = 'Denesik and Sons Party'
What is the distinct service types that are provided by the organization which has detail 'Denesik and Sons Party'?
local_govt_and_lot
SELECT t1.resident_id , t1.other_details , count(*) FROM residents AS t1 JOIN residents_services AS t2 ON t1.resident_id = t2.resident_id GROUP BY t1.resident_id ORDER BY count(*) DESC
How many services has each resident requested? List the resident id, details, and the count in descending order of the count.
local_govt_and_lot
SELECT T1.service_id , T1.service_details , count(*) FROM Services AS T1 JOIN Residents_Services AS T2 ON T1.service_id = T2.service_id GROUP BY T1.service_id ORDER BY count(*) DESC LIMIT 1
What is the maximum number that a certain service is provided? List the service id, details and number.
local_govt_and_lot
SELECT T1.customer_id , T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 3
What are the id and details of the customers who have at least 3 events?
local_govt_and_lot
SELECT T1.Customer_Event_ID , T1.property_id FROM Customer_Events AS T1 JOIN Customer_Event_Notes AS T2 ON T1.Customer_Event_ID = T2.Customer_Event_ID GROUP BY T1.customer_event_id HAVING count(*) BETWEEN 1 AND 3
Which events have the number of notes between one and three? List the event id and the property id.
local_govt_and_lot
SELECT DISTINCT T2.thing_id , T2.Type_of_Thing_Code FROM Timed_Status_of_Things AS T1 JOIN Things AS T2 ON T1.thing_id = T2.thing_id WHERE T1.Status_of_Thing_Code = 'Close' OR T1.Date_and_Date < '2017-06-19 02:59:21'
What are the distinct id and type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21'
local_govt_and_lot
SELECT count(DISTINCT T2.Location_Code) FROM Things AS T1 JOIN Timed_Locations_of_Things AS T2 ON T1.thing_id = T2.thing_id WHERE T1.service_details = 'Unsatisfied'
How many distinct locations have the things with service detail 'Unsatisfied' been located in?
local_govt_and_lot
SELECT organization_id FROM organizations EXCEPT SELECT parent_organization_id FROM organizations
Which organizations are not a parent organization of others? List the organization id.
local_govt_and_lot
SELECT other_details FROM Residents WHERE other_details LIKE '%Miss%'
What are the resident details containing the substring 'Miss'?
product_catalog
SELECT attribute_data_type FROM Attribute_Definitions GROUP BY attribute_data_type HAVING count(*) > 3
Find the list of attribute data types possessed by more than 3 attribute definitions.
product_catalog
SELECT distinct(catalog_publisher) FROM catalogs WHERE catalog_publisher LIKE "%Murray%"
Find all the catalog publishers whose name contains "Murray"
product_catalog
SELECT catalog_publisher FROM catalogs GROUP BY catalog_publisher ORDER BY count(*) DESC LIMIT 1
Which catalog publisher has published the most catalogs?
product_catalog
SELECT t1.catalog_name , t1.date_of_publication FROM catalogs AS t1 JOIN catalog_structure AS t2 ON t1.catalog_id = t2.catalog_id WHERE catalog_level_number > 5
Find the names and publication dates of all catalogs that have catalog level number greater than 5.
product_catalog
SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.attribute_value = (SELECT attribute_value FROM Catalog_Contents_Additional_Attributes GROUP BY attribute_value ORDER BY count(*) DESC LIMIT 1)
What are the entry names of catalog with the attribute possessed by most entries.
product_catalog
SELECT catalog_entry_name FROM catalog_contents ORDER BY price_in_dollars DESC LIMIT 1
What is the entry name of the most expensive catalog (in USD)?
product_catalog
SELECT t2.catalog_level_name FROM catalog_contents AS t1 JOIN catalog_structure AS t2 ON t1.catalog_level_number = t2.catalog_level_number ORDER BY t1.price_in_dollars LIMIT 1
What is the level name of the cheapest catalog (in USD)?
product_catalog
SELECT avg(price_in_euros) , min(price_in_euros) FROM catalog_contents
What are the average and minimum price (in Euro) of all products?
product_catalog
SELECT catalog_entry_name FROM catalog_contents ORDER BY height DESC LIMIT 1
What is the product with the highest height? Give me the catalog entry name.
product_catalog
SELECT catalog_entry_name FROM catalog_contents ORDER BY capacity ASC LIMIT 1
Find the name of the product that has the smallest capacity.
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE product_stock_number LIKE "2%"
Find the names of all the products whose stock number starts with "2".
product_catalog
SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.catalog_level_number = "8"
Find the names of catalog entries with level number 8.
product_catalog
SELECT catalog_entry_name FROM catalog_contents WHERE LENGTH < 3 OR width > 5
Find the names of the products with length smaller than 3 or height greater than 5.
product_catalog
SELECT t1.attribute_name , t1.attribute_id FROM Attribute_Definitions AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.attribute_id = t2.attribute_id WHERE t2.attribute_value = 0
Find the name and attribute ID of the attribute definitions with attribute value 0.
entertainment_awards
SELECT LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC LIMIT 1
What is the location of the festival with the largest number of audience?
entertainment_awards
SELECT Festival_Name FROM festival_detail ORDER BY YEAR DESC LIMIT 3
Show the names of the three most recent festivals.
entertainment_awards
SELECT T2.Name , T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID
For each nomination, show the name of the artwork and name of the festival where it is nominated.
entertainment_awards
SELECT DISTINCT T2.Type FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T3.Year = 2007
Show distinct types of artworks that are nominated in festivals in 2007.
entertainment_awards
SELECT T2.Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID ORDER BY T3.Year
Show the names of artworks in ascending order of the year they are nominated in.
entertainment_awards
SELECT T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID WHERE T2.Type = "Program Talent Show"
Show the names of festivals that have nominated artworks of type "Program Talent Show".
entertainment_awards
SELECT T1.Festival_ID , T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID HAVING COUNT(*) >= 2
Show the ids and names of festivals that have at least two nominations for artworks.
entertainment_awards
SELECT T1.Festival_ID , T3.Festival_Name , COUNT(*) FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID GROUP BY T1.Festival_ID
Show the id, name of each festival and the number of artworks it has nominated.
entertainment_awards
SELECT TYPE FROM artwork GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1
List the most common type of artworks.
entertainment_awards
SELECT YEAR FROM festival_detail GROUP BY YEAR HAVING COUNT(*) > 1
List the year in which there are more than one festivals.
entertainment_awards
SELECT Name FROM Artwork WHERE Artwork_ID NOT IN (SELECT Artwork_ID FROM nomination)
List the name of artworks that are not nominated.
entertainment_awards
SELECT Num_of_Audience FROM festival_detail WHERE YEAR = 2008 OR YEAR = 2010
Show the number of audience in year 2008 or 2010.
behavior_monitoring
SELECT email_address FROM Students WHERE first_name = "Emma" AND last_name = "Rohan"
What is the email of the student with first name "Emma" and last name "Rohan"?
behavior_monitoring
SELECT max(monthly_rental) , min(monthly_rental) FROM Student_Addresses
Find the maximum and minimum monthly rental for all student addresses.
behavior_monitoring
SELECT first_name FROM Teachers WHERE email_address LIKE '%man%'
Find the first names of teachers whose email address contains the word "man".
behavior_monitoring
SELECT T1.student_id , T2.first_name FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
Find the id and first name of the student that has the most number of assessment notes?
behavior_monitoring
SELECT T1.teacher_id , T2.first_name FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 3
Find the ids and first names of the 3 teachers that have the most number of assessment notes?
behavior_monitoring
SELECT T1.student_id , T2.last_name FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
Find the id and last name of the student that has the most behavior incidents?
behavior_monitoring
SELECT T1.teacher_id , T2.last_name FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T1.detention_type_code = "AFTER" GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 1
Find the id and last name of the teacher that has the most detentions with detention type code "AFTER"?
behavior_monitoring
SELECT T1.student_id , T2.first_name FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY AVG(monthly_rental) DESC LIMIT 1
What are the id and first name of the student whose addresses have the highest average monthly rental?
behavior_monitoring
SELECT T2.address_id , T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id ORDER BY AVG(monthly_rental) DESC LIMIT 1
Find the id and city of the student address with the highest average monthly rental.
behavior_monitoring
SELECT T1.incident_type_code , T2.incident_type_description FROM Behavior_Incident AS T1 JOIN Ref_Incident_Type AS T2 ON T1.incident_type_code = T2.incident_type_code GROUP BY T1.incident_type_code ORDER BY count(*) DESC LIMIT 1
What are the code and description of the most frequent behavior incident type?
behavior_monitoring
SELECT T1.detention_type_code , T2.detention_type_description FROM Detention AS T1 JOIN Ref_Detention_Type AS T2 ON T1.detention_type_code = T2.detention_type_code GROUP BY T1.detention_type_code ORDER BY count(*) ASC LIMIT 1
What are the code and description of the least frequent detention type ?
behavior_monitoring
SELECT T1.date_of_notes FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = "Fanny"
Find the dates of assessment notes for students with first name "Fanny".
behavior_monitoring
SELECT T1.text_of_notes FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schuster"
Find the texts of assessment notes for teachers with last name "Schuster".
behavior_monitoring
SELECT T1.date_incident_start , date_incident_end FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.last_name = "Fahey"
Find the start and end dates of behavior incidents of students with last name "Fahey".
behavior_monitoring
SELECT T1.datetime_detention_start , datetime_detention_end FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schultz"
Find the start and end dates of detentions of teachers with last name "Schultz".
behavior_monitoring
SELECT T2.address_id , T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id ORDER BY monthly_rental DESC LIMIT 1
What are the id and zip code of the address with the highest monthly rental?
behavior_monitoring
SELECT T2.cell_mobile_number FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.monthly_rental ASC LIMIT 1
What is the cell phone number of the student whose address has the lowest monthly rental?
behavior_monitoring
SELECT T2.monthly_rental FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Texas"
What are the monthly rentals of student addresses in Texas state?
behavior_monitoring
SELECT T2.first_name , T2.last_name FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Wisconsin"
What are the first names and last names of students with address in Wisconsin state?
behavior_monitoring
SELECT T1.line_1 , avg(T2.monthly_rental) FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id
What are the line 1 and average monthly rentals of all student addresses?
behavior_monitoring
SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = "Lyla"
What is the zip code of the address where the teacher with first name "Lyla" lives?
behavior_monitoring
SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T1.zip_postcode = "918"
What are the email addresses of teachers whose address has zip code "918"?
behavior_monitoring
SELECT count(*) FROM STUDENTS WHERE student_id NOT IN ( SELECT student_id FROM Behavior_Incident )
How many students are not involved in any behavior incident?
behavior_monitoring
SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id = T2.teacher_id
Find the last names of teachers who are not involved in any detention.
e_government
SELECT individual_first_name , individual_middle_name , individual_last_name FROM individuals ORDER BY individual_last_name
List every individual's first name, middle name and last name in alphabetical order by last name.
e_government
SELECT DISTINCT form_type_code FROM forms
List all the types of forms.
e_government
SELECT t1.form_name FROM forms AS t1 JOIN party_forms AS t2 ON t1.form_id = t2.form_id GROUP BY t2.form_id ORDER BY count(*) DESC LIMIT 1
Find the name of the most popular party form.
e_government
SELECT payment_method_code , party_phone FROM parties WHERE party_email = "enrico09@example.com"
Find the payment method and phone of the party with email "enrico09@example.com".
e_government
SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id = t2.party_id WHERE t2.form_id = (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY count(*) DESC LIMIT 1)
Find the emails of parties with the most popular party form.
e_government
SELECT organization_name FROM organizations ORDER BY date_formed ASC
List all the name of organizations in order of the date formed.
e_government
SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1
Find the name of the youngest organization.
e_government
SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.organization_name = "Labour Party" ORDER BY t2.date_contact_to DESC LIMIT 1
Find the last name of the latest contact individual of the organization "Labour Party".
e_government
SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.uk_vat_number = (SELECT max(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to ASC LIMIT...
Find the last name of the first ever contact person of the organization with the highest UK Vat number.
e_government
SELECT service_name FROM services EXCEPT SELECT t1.service_name FROM services AS t1 JOIN party_services AS t2 ON t1.service_id = t2.service_id
Find the names of the services that have never been used.
e_government
SELECT town_city FROM addresses UNION SELECT state_province_county FROM addresses
Find the name of all the cities and states.
e_government
SELECT count(*) FROM addresses WHERE state_province_county = "Colorado"
How many cities are there in state "Colorado"?
e_government
SELECT payment_method_code FROM parties GROUP BY payment_method_code HAVING count(*) > 3
Find the payment method code used by more than 3 parties.
e_government
SELECT organization_name FROM organizations WHERE organization_name LIKE "%Party%"
Find the name of organizations whose names contain "Party".
e_government
SELECT count(DISTINCT payment_method_code) FROM parties
How many distinct payment methods are used by parties?
e_government
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
Which is the email of the party that has used the services the most number of times?
e_government
SELECT state_province_county FROM addresses WHERE line_1_number_building LIKE "%6862 Kaitlyn Knolls%"
Which state can address "6862 Kaitlyn Knolls" possibly be in?
e_government
SELECT t1.organization_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id GROUP BY t1.organization_name ORDER BY count(*) DESC LIMIT 1
What is the name of organization that has the greatest number of contact individuals?
products_for_hire
SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id = T2.coupon_id WHERE T2.coupon_amount = 500
Are the customers holding coupons with amount 500 bad or good?
products_for_hire
SELECT T1.customer_id , T1.first_name , count(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id
How many bookings did each customer make? List the customer id, first name, and the count.
products_for_hire
SELECT customer_id , sum(amount_paid) FROM Payments GROUP BY customer_id ORDER BY sum(amount_paid) DESC LIMIT 1
What is the maximum total amount paid by a customer? List the customer id and amount.
products_for_hire
SELECT T1.booking_id , T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id = T2.booking_id GROUP BY T1.booking_id ORDER BY count(*) DESC LIMIT 1
What are the id and the amount of refund of the booking that incurred the most times of payments?
products_for_hire
SELECT product_id FROM products_booked GROUP BY product_id HAVING count(*) = 3
What is the id of the product that is booked for 3 times?
products_for_hire
SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.booked_amount = 102.76
What is the product description of the product booked with an amount of 102.76?
products_for_hire
SELECT T3.booking_start_date , T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id = T2.product_id JOIN bookings AS T3 ON T2.booking_id = T3.booking_id WHERE T1.product_name = 'Book collection A'
What are the start date and end date of the booking that has booked the product named 'Book collection A'?
products_for_hire
SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id = T2.product_id WHERE T1.available_yn = 1
What are the names of products whose availability equals to 1?