database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
e_learning
SELECT T1.course_name , COUNT(*) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name
What is the name of each course and the corresponding number of student enrollment?
e_learning
SELECT T1.date_of_enrolment FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Pass"
What are the enrollment dates of all the tests that have result "Pass"?
e_learning
SELECT T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Fail"
What are the completion dates of all the tests that have result "Fail"?
e_learning
SELECT T1.date_of_enrolment , T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.personal_name = "Karson"
List the dates of enrollment and completion of the student with personal name "Karson".
e_learning
SELECT T1.date_of_enrolment , T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.family_name = "Zieme" AND T2.personal_name = "Bernie"
List the dates of enrollment and completion of the student with family name "Zieme" and personal name "Bernie".
e_learning
SELECT T1.student_id , T2.login_name FROM Student_Course_Enrolment 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 student ID and login name of the student with the most course enrollments
e_learning
SELECT T1.student_id , T2.personal_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) >= 2
Find the student ID and personal name of the student with at least two enrollments.
e_learning
SELECT T1.student_id , T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) <= 2
Find the student ID and middle name for all the students with at most two enrollments.
e_learning
SELECT personal_name FROM Students EXCEPT SELECT T1.personal_name FROM Students AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.student_id = T2.student_id
Find the personal names of students not enrolled in any course.
e_learning
SELECT count(*) FROM Students WHERE student_id NOT IN (SELECT student_id FROM Student_Course_Enrolment)
How many students did not have any course enrollment?
e_learning
SELECT login_name FROM Course_Authors_and_Tutors INTERSECT SELECT login_name FROM Students
Find the common login name of course authors and students.
sports_competition
SELECT max(Silver) , min(Silver) FROM club_rank
What are the maximum and minimum number of silver medals for clubs.
sports_competition
SELECT T1.name FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T2.Position = "Right Wing"
Show the names of clubs that have players with position "Right Wing".
sports_competition
SELECT avg(T2.Points) FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID WHERE T1.name = "AIB"
What is the average points of players from club with name "AIB".
sports_competition
SELECT POSITION FROM player GROUP BY name HAVING avg(Points) >= 20
List the position of players with average number of points scored by players of that position bigger than 20.
sports_competition
SELECT Competition_type FROM competition GROUP BY Competition_type ORDER BY COUNT(*) DESC LIMIT 1
List the most common type of competition.
sports_competition
SELECT Competition_type FROM competition GROUP BY Competition_type HAVING COUNT(*) <= 5
List the types of competition that have at most five competitions of that type.
sports_competition
SELECT name FROM CLub WHERE Club_ID NOT IN (SELECT Club_ID FROM player)
List the names of clubs that do not have any players.
sports_competition
SELECT POSITION FROM player WHERE Points > 20 INTERSECT SELECT POSITION FROM player WHERE Points < 10
What are the positions with both players having more than 20 points and less than 10 points.
sports_competition
SELECT name FROM player WHERE points > (SELECT avg(points) FROM player)
what are the name of players who get more than the average points.
sports_competition
SELECT count(*) , POSITION FROM player WHERE points < 30 GROUP BY POSITION
find the number of players whose points are lower than 30 in each position.
sports_competition
SELECT country FROM competition WHERE competition_type = 'Tournament' GROUP BY country ORDER BY count(*) DESC LIMIT 1
which country did participated in the most number of Tournament competitions?
sports_competition
SELECT country FROM competition WHERE competition_type = 'Friendly' INTERSECT SELECT country FROM competition WHERE competition_type = 'Tournament'
which countries did participated in both Friendly and Tournament type competitions.
assets_maintenance
SELECT T1.asset_id , T1.asset_details FROM Assets AS T1 JOIN Asset_Parts AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING count(*) = 2 INTERSECT SELECT T1.asset_id , T1.asset_details FROM Assets AS T1 JOIN Fault_Log AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING count(*) < 2
Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail.
assets_maintenance
SELECT count(*) , T1.maintenance_contract_id FROM Maintenance_Contracts AS T1 JOIN Assets AS T2 ON T1.maintenance_contract_id = T2.maintenance_contract_id GROUP BY T1.maintenance_contract_id
How many assets does each maintenance contract contain? List the number and the contract id.
assets_maintenance
SELECT count(*) , T1.company_id FROM Third_Party_Companies AS T1 JOIN Assets AS T2 ON T1.company_id = T2.supplier_company_id GROUP BY T1.company_id
How many assets does each third party company supply? List the count and the company id.
assets_maintenance
SELECT T1.company_id , T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING count(*) >= 2 UNION SELECT T3.company_id , T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id = ...
Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.
assets_maintenance
SELECT T1.staff_name , T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id = T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name , T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id = T4.contact_staff_id
What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers?
assets_maintenance
SELECT T1.engineer_id , T1.first_name , T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 GROUP BY T1.engineer_id ORDER BY count(*) DESC LIMIT 1
Which engineer has visited the most times? Show the engineer id, first name and last name.
assets_maintenance
SELECT T1.part_name , T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_id HAVING count(*) > 2
Which parts have more than 2 faults? Show the part name and id.
assets_maintenance
SELECT T1.first_name , T1.last_name , T1.other_details , T3.skill_description FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id
List all every engineer's first name, last name, details and coresponding skill description.
assets_maintenance
SELECT T1.fault_short_name , T3.skill_description FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id
For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description.
assets_maintenance
SELECT T1.part_name , count(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name
How many assets can each parts be used in? List the part name and the number.
assets_maintenance
SELECT count(*) , T1.fault_log_entry_id FROM Fault_Log AS T1 JOIN Engineer_Visits AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY count(*) DESC LIMIT 1
How many engineer visits are required at most for a single fault log? List the number and the log entry id.
assets_maintenance
SELECT first_name , last_name FROM Maintenance_Engineers WHERE engineer_id NOT IN (SELECT engineer_id FROM Engineer_Visits)
Which engineers have never visited to maintain the assets? List the engineer first name and last name.
assets_maintenance
SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date ASC LIMIT 1
When was the first asset acquired?
assets_maintenance
SELECT T1.part_id , T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id JOIN Skills_Required_To_Fix AS T3 ON T2.part_fault_id = T3.part_fault_id GROUP BY T1.part_id ORDER BY count(*) DESC LIMIT 1
Which part fault requires the most number of skills to fix? List part id and name.
assets_maintenance
SELECT T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY count(*) ASC LIMIT 1
Which kind of part has the least number of faults? List the part name.
assets_maintenance
SELECT T1.engineer_id , T1.first_name , T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 ON T1.engineer_id = T2.engineer_id GROUP BY T1.engineer_id ORDER BY count(*) ASC LIMIT 1
Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name.
assets_maintenance
SELECT T1.staff_name , T3.first_name , T3.last_name FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id JOIN Maintenance_Engineers AS T3 ON T2.engineer_id = T3.engineer_id
Which staff have contacted which engineers? List the staff name and the engineer first name and last name.
assets_maintenance
SELECT T1.fault_log_entry_id , T1.fault_description , T1.fault_log_entry_datetime FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY count(*) DESC LIMIT 1
Which fault log included the most number of faulty parts? List the fault log id, description and record time.
assets_maintenance
SELECT T1.skill_id , T1.skill_description FROM Skills AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.skill_id = T2.skill_id GROUP BY T1.skill_id ORDER BY count(*) DESC LIMIT 1
Which skill is used in fixing the most number of faults? List the skill id and description.
assets_maintenance
SELECT part_id , chargeable_amount FROM Parts ORDER BY chargeable_amount ASC LIMIT 1
Which part has the least chargeable amount? List the part id and amount.
assets_maintenance
SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id ORDER BY T2.contract_start_date ASC LIMIT 1
Which company started the earliest the maintenance contract? Show the company name.
assets_maintenance
SELECT gender FROM staff GROUP BY gender ORDER BY count(*) DESC LIMIT 1
Which gender makes up the majority of the staff?
assets_maintenance
SELECT T1.staff_name , count(*) FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id GROUP BY T1.staff_name
How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.
station_weather
SELECT local_authority , services FROM station;
list the local authorities and services provided by all stations.
station_weather
SELECT train_number , name FROM train ORDER BY TIME;
show all train numbers and names ordered by their time from early to late.
station_weather
SELECT TIME , train_number FROM train WHERE destination = 'Chennai' ORDER BY TIME;
Give me the times and numbers of all trains that go to Chennai, ordered by time.
station_weather
SELECT count(*) FROM train WHERE name LIKE "%Express%";
How many trains have 'Express' in their names?
station_weather
SELECT train_number , TIME FROM train WHERE origin = 'Chennai' AND destination = 'Guruvayur';
Find the number and time of the train that goes from Chennai to Guruvayur.
station_weather
SELECT origin , count(*) FROM train GROUP BY origin;
Find the number of trains starting from each origin.
station_weather
SELECT t1.name FROM train AS t1 JOIN route AS t2 ON t1.id = t2.train_id GROUP BY t2.train_id ORDER BY count(*) DESC LIMIT 1;
Find the name of the train whose route runs through greatest number of stations.
station_weather
SELECT count(*) , t1.network_name , t1.services FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id GROUP BY t2.station_id;
Find the number of trains for each station, as well as the station network name and services.
station_weather
SELECT avg(high_temperature) , day_of_week FROM weekly_weather GROUP BY day_of_week;
What is the average high temperature for each day of week?
station_weather
SELECT max(t1.low_temperature) , avg(t1.precipitation) FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id WHERE t2.network_name = "Amersham";
Give me the maximum low temperature and average precipitation at the Amersham station.
station_weather
SELECT t3.name , t3.time FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id JOIN train AS t3 ON t2.train_id = t3.id WHERE t1.local_authority = "Chiltern";
Find names and times of trains that run through stations for the local authority Chiltern.
station_weather
SELECT count(DISTINCT services) FROM station;
How many different services are provided by all stations?
station_weather
SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id ORDER BY avg(high_temperature) DESC LIMIT 1
Find the id and local authority of the station with has the highest average high temperature.
station_weather
SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id HAVING max(t1.precipitation) > 50;
Find the id and local authority of the station whose maximum precipitation is higher than 50.
station_weather
SELECT min(low_temperature) , max(wind_speed_mph) FROM weekly_weather;
show the lowest low temperature and highest wind speed in miles per hour.
culture_company
SELECT count(*) FROM book_club
How many book clubs are there?
culture_company
SELECT book_title , author_or_editor FROM book_club WHERE YEAR > 1989
show the titles, and authors or editors for all books made after the year 1989.
culture_company
SELECT DISTINCT publisher FROM book_club
Show all distinct publishers for books.
culture_company
SELECT YEAR , book_title , publisher FROM book_club ORDER BY YEAR DESC
Show the years, book titles, and publishers for all books, in descending order by year.
culture_company
SELECT publisher , count(*) FROM book_club GROUP BY publisher
Show all publishers and the number of books for each publisher.
culture_company
SELECT publisher FROM book_club GROUP BY publisher ORDER BY count(*) DESC LIMIT 1
What is the publisher with most number of books?
culture_company
SELECT category , count(*) FROM book_club GROUP BY category
Show all book categories and the number of books in each category.
culture_company
SELECT category FROM book_club WHERE YEAR > 1989 GROUP BY category HAVING count(*) >= 2
List categories that have at least two books after year 1989.
culture_company
SELECT publisher FROM book_club WHERE YEAR = 1989 INTERSECT SELECT publisher FROM book_club WHERE YEAR = 1990
Show publishers with a book published in 1989 and a book in 1990.
culture_company
SELECT publisher FROM book_club EXCEPT SELECT publisher FROM book_club WHERE YEAR = 1989
Show all publishers which do not have a book in 1989.
culture_company
SELECT title , YEAR , director FROM movie ORDER BY budget_million
Show all movie titles, years, and directors, ordered by budget.
culture_company
SELECT COUNT (DISTINCT director) FROM movie
How many movie directors are there?
culture_company
SELECT title , director FROM movie WHERE YEAR <= 2000 ORDER BY gross_worldwide DESC LIMIT 1
What is the title and director for the movie with highest worldwide gross in the year 2000 or before?
culture_company
SELECT director FROM movie WHERE YEAR = 2000 INTERSECT SELECT director FROM movie WHERE YEAR = 1999
Show all director names who have a movie in both year 1999 and 2000.
culture_company
SELECT director FROM movie WHERE YEAR = 1999 OR YEAR = 2000
Show all director names who have a movie in the year 1999 or 2000.
culture_company
SELECT avg(budget_million) , max(budget_million) , min(budget_million) FROM movie WHERE YEAR < 2000
What is the average, maximum, and minimum budget for all movies before 2000.
culture_company
SELECT T1.company_name FROM culture_company AS T1 JOIN book_club AS T2 ON T1.book_club_id = T2.book_club_id WHERE T2.publisher = 'Alyson'
List all company names with a book published by Alyson.
culture_company
SELECT T1.title , T3.book_title FROM movie AS T1 JOIN culture_company AS T2 ON T1.movie_id = T2.movie_id JOIN book_club AS T3 ON T3.book_club_id = T2.book_club_id WHERE T2.incorporated_in = 'China'
Show the movie titles and book titles for all companies in China.
architecture
SELECT count(*) FROM architect WHERE gender = 'female'
How many architects are female?
architecture
SELECT name , nationality , id FROM architect WHERE gender = 'male' ORDER BY name
List the name, nationality and id of all male architects ordered by their names lexicographically.
architecture
SELECT max(T1.length_meters) , T2.name FROM bridge AS T1 JOIN architect AS T2 ON T1.architect_id = T2.id
What is the maximum length in meters for the bridges and what are the architects' names?
architecture
SELECT avg(length_feet) FROM bridge
What is the average length in feet of the bridges?
architecture
SELECT name , built_year FROM mill WHERE TYPE = 'Grondzeiler'
What are the names and year of construction for the mills of 'Grondzeiler' type?
architecture
SELECT DISTINCT T1.name , T1.nationality FROM architect AS T1 JOIN mill AS t2 ON T1.id = T2.architect_id
What are the distinct names and nationalities of the architects who have ever built a mill?
architecture
SELECT name FROM mill WHERE LOCATION != 'Donceel'
What are the names of the mills which are not located in 'Donceel'?
architecture
SELECT DISTINCT T1.type FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id = T2.id WHERE T2.nationality = 'American' OR T2.nationality = 'Canadian'
What are the distinct types of mills that are built by American or Canadian architects?
architecture
SELECT T1.id , T1.name FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING count(*) >= 3
What are the ids and names of the architects who built at least 3 bridges ?
architecture
SELECT T1.id , T1.name , T1.nationality FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1
What is the id, name and nationality of the architect who built most mills?
architecture
SELECT T1.id , T1.name , T1.gender FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING count(*) = 2 UNION SELECT T1.id , T1.name , T1.gender FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING count(*) = 1
What are the ids, names and genders of the architects who built two bridges or one mill?
architecture
SELECT LOCATION FROM bridge WHERE name = 'Kolob Arch' OR name = 'Rainbow Bridge'
What is the location of the bridge named 'Kolob Arch' or 'Rainbow Bridge'?
architecture
SELECT name FROM mill WHERE name LIKE '%Moulin%'
Which of the mill names contains the french word 'Moulin'?
architecture
SELECT DISTINCT T1.name FROM mill AS T1 JOIN architect AS t2 ON T1.architect_id = T2.id JOIN bridge AS T3 ON T3.architect_id = T2.id WHERE T3.length_meters > 80
What are the distinct name of the mills built by the architects who have also built a bridge longer than 80 meters?
architecture
SELECT TYPE , count(*) FROM mill GROUP BY TYPE ORDER BY count(*) DESC LIMIT 1
What is the most common mill type, and how many are there?
architecture
SELECT count(*) FROM architect WHERE id NOT IN ( SELECT architect_id FROM mill WHERE built_year < 1850 );
How many architects haven't built a mill before year 1850?
school_finance
SELECT sum(enrollment) , avg(enrollment) FROM school
What are the total and average enrollment of all schools?
school_finance
SELECT mascot FROM school WHERE enrollment > (SELECT avg(enrollment) FROM school)
What are the mascots for schools with enrollments above the average?
school_finance
SELECT school_name FROM school ORDER BY enrollment LIMIT 1
List the name of the school with the smallest enrollment.
school_finance
SELECT avg(enrollment) , max(enrollment) , min(enrollment) FROM school
Show the average, maximum, minimum enrollment of all schools.
school_finance
SELECT county , count(*) , sum(enrollment) FROM school GROUP BY county
Show each county along with the number of schools and total enrollment in each county.