Question: Show the locations that have both performances with more than 2000 attendees and performances with less than 1000 attendees.

Context: CREATE TABLE performance (LOCATION VARCHAR, Attendance INTEGER)

SELECT LOCATION FROM performance WHERE Attendance > 2000 INTERSECT SELECT LOCATION FROM performance WHERE Attendance < 1000


Question: Show the names of members and the location of the performances they attended.

Context: CREATE TABLE performance (Location VARCHAR, Performance_ID VARCHAR); CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR); CREATE TABLE member_attendance (Member_ID VARCHAR, Performance_ID VARCHAR)

SELECT T2.Name, T3.Location 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


Question: Show the names of members and the location of performances they attended in ascending alphabetical order of their names.

SELECT T2.Name, T3.Location 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 T2.Name


Question: Show the dates of performances with attending members whose roles are "Violin".

Context: CREATE TABLE performance (Date VARCHAR, Performance_ID VARCHAR); CREATE TABLE member (Member_ID VARCHAR, Role VARCHAR); CREATE TABLE member_attendance (Member_ID VARCHAR, Performance_ID VARCHAR)

SELECT 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 WHERE T2.Role = "Violin"


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

Context: CREATE TABLE performance (Date VARCHAR, Performance_ID VARCHAR, Attendance VARCHAR); CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR); CREATE TABLE member_attendance (Member_ID VARCHAR, Performance_ID VARCHAR)

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: List the names of members who did not attend any performance.

Context: CREATE TABLE member (Name VARCHAR, Member_ID VARCHAR); CREATE TABLE member_attendance (Name VARCHAR, Member_ID VARCHAR)

SELECT Name FROM member WHERE NOT Member_ID IN (SELECT Member_ID FROM member_attendance)


Question: Find the buildings which have rooms with capacity more than 50.

Context: CREATE TABLE classroom (building VARCHAR, capacity INTEGER)

SELECT DISTINCT building FROM classroom WHERE capacity > 50


Question: Count the number of rooms that are not in the Lamberton building.

Context: CREATE TABLE classroom (building VARCHAR)

SELECT COUNT(*) FROM classroom WHERE building <> 'Lamberton'


Question: What is the name and building of the departments whose budget is more than the average budget?

Context: CREATE TABLE department (dept_name VARCHAR, building VARCHAR, budget INTEGER)

SELECT dept_name, building FROM department WHERE budget > (SELECT AVG(budget) FROM department)


Question: Find the room number of the rooms which can sit 50 to 100 students and their buildings.

Context: CREATE TABLE classroom (building VARCHAR, room_number VARCHAR, capacity INTEGER)

SELECT building, room_number FROM classroom WHERE capacity BETWEEN 50 AND 100


Question: Find the name and building of the department with the highest budget.

Context: CREATE TABLE department (dept_name VARCHAR, building VARCHAR, budget VARCHAR)

SELECT dept_name, building FROM department ORDER BY budget DESC LIMIT 1


Question: What is the name of the student who has the highest total credits in the History department.

Context: CREATE TABLE student (name VARCHAR, dept_name VARCHAR, tot_cred VARCHAR)

SELECT name FROM student WHERE dept_name = 'History' ORDER BY tot_cred DESC LIMIT 1


Question: How many rooms does the Lamberton building have?

SELECT COUNT(*) FROM classroom WHERE building = 'Lamberton'


Question: How many students have advisors?

Context: CREATE TABLE advisor (s_id VARCHAR)

SELECT COUNT(DISTINCT s_id) FROM advisor


Question: How many departments offer courses?

Context: CREATE TABLE course (dept_name VARCHAR)

SELECT COUNT(DISTINCT dept_name) FROM course


Question: How many different courses offered by Physics department?

Context: CREATE TABLE course (course_id VARCHAR, dept_name VARCHAR)

SELECT COUNT(DISTINCT course_id) FROM course WHERE dept_name = 'Physics'


Question: Find the title of courses that have two prerequisites?

Context: CREATE TABLE prereq (course_id VARCHAR); CREATE TABLE course (title VARCHAR, course_id VARCHAR)

SELECT T1.title FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING COUNT(*) = 2


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

Context: CREATE TABLE prereq (course_id VARCHAR); CREATE TABLE course (title VARCHAR, credits VARCHAR, dept_name VARCHAR, course_id VARCHAR)

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 courses that do not have prerequisite?

Context: CREATE TABLE prereq (course_id VARCHAR); CREATE TABLE course (course_id VARCHAR)

SELECT COUNT(*) FROM course WHERE NOT course_id IN (SELECT course_id FROM prereq)


Question: Find the name of the courses that do not have any prerequisite?

Context: CREATE TABLE prereq (title VARCHAR, course_id VARCHAR); CREATE TABLE course (title VARCHAR, course_id VARCHAR)

SELECT title FROM course WHERE NOT course_id IN (SELECT course_id FROM prereq)


Question: How many different instructors have taught some course?

Context: CREATE TABLE teaches (id VARCHAR)


Question: Find the total budgets of the Marketing or Finance department.

Context: CREATE TABLE department (budget INTEGER, dept_name VARCHAR)

SELECT SUM(budget) FROM department WHERE dept_name = 'Marketing' OR dept_name = 'Finance'


Question: Find the department name of the instructor whose name contains 'Soisalon'.

Context: CREATE TABLE instructor (dept_name VARCHAR, name VARCHAR)

SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%'


Question: How many rooms whose capacity is less than 50 does the Lamberton building have?

Context: CREATE TABLE classroom (building VARCHAR, capacity VARCHAR)

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


Question: Find the name and budget of departments whose budgets are more than the average budget.

Context: CREATE TABLE department (dept_name VARCHAR, budget INTEGER)

SELECT dept_name, budget FROM department WHERE budget > (SELECT AVG(budget) FROM department)


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

Context: CREATE TABLE instructor (name VARCHAR, dept_name VARCHAR, salary VARCHAR)

SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary LIMIT 1


Question: Find the title of course that is provided by both Statistics and Psychology departments.

Context: CREATE TABLE course (title VARCHAR, dept_name VARCHAR)

SELECT title FROM course WHERE dept_name = 'Statistics' INTERSECT SELECT title FROM course WHERE dept_name = 'Psychology'


Question: Find the title of course that is provided by Statistics but not Psychology departments.

SELECT title FROM course WHERE dept_name = 'Statistics' EXCEPT SELECT title FROM course WHERE dept_name = 'Psychology'


Question: Find the id of instructors who taught a class in Fall 2009 but not in Spring 2010.

Context: CREATE TABLE teaches (id VARCHAR, semester VARCHAR, YEAR VARCHAR)

SELECT id FROM teaches WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT id FROM teaches WHERE semester = 'Spring' AND YEAR = 2010


Question: Find the name of students who took any class in the years of 2009 and 2010.

Context: CREATE TABLE student (name VARCHAR, id VARCHAR); CREATE TABLE takes (id VARCHAR)

SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id = T2.id WHERE YEAR = 2009 OR YEAR = 2010


Question: Find the names of the top 3 departments that provide the largest amount of courses?

Context: CREATE TABLE course (dept_name VARCHAR)

SELECT dept_name FROM course GROUP BY dept_name ORDER BY COUNT(*) DESC LIMIT 3


Question: Find the name of the department that offers the highest total credits?

Context: CREATE TABLE course (dept_name VARCHAR, credits INTEGER)

SELECT dept_name FROM course GROUP BY dept_name ORDER BY SUM(credits) DESC LIMIT 1


Question: List the names of all courses ordered by their titles and credits.

Context: CREATE TABLE course (title VARCHAR, credits VARCHAR)

SELECT title FROM course ORDER BY title, credits


Question: Which department has the lowest budget?

Context: CREATE TABLE department (dept_name VARCHAR, budget VARCHAR)

SELECT dept_name FROM department ORDER BY budget LIMIT 1


Question: List the names and buildings of all departments sorted by the budget from large to small.

Context: CREATE TABLE department (dept_name VARCHAR, building VARCHAR, budget VARCHAR)

SELECT dept_name, building FROM department ORDER BY budget DESC


Question: Who is the instructor with the highest salary?

Context: CREATE TABLE instructor (name VARCHAR, salary VARCHAR)

SELECT name FROM instructor ORDER BY salary DESC LIMIT 1


Question: List the information of all instructors ordered by their salary in ascending order.

Context: CREATE TABLE instructor (salary VARCHAR)

SELECT * FROM instructor ORDER BY salary


Question: Find the name of the students and their department names sorted by their total credits in ascending order.

Context: CREATE TABLE student (name VARCHAR, dept_name VARCHAR, tot_cred VARCHAR)

SELECT name, dept_name FROM student ORDER BY tot_cred


Question: list in alphabetic order all course names and their instructors' names in year 2008.

Context: CREATE TABLE course (title VARCHAR, course_id VARCHAR); CREATE TABLE teaches (course_id VARCHAR, id VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR)

SELECT T1.title, T3.name FROM course AS T1 JOIN teaches AS T2 ON T1.course_id = T2.course_id JOIN instructor AS T3 ON T2.id = T3.id WHERE YEAR = 2008 ORDER BY T1.title


Question: Find the name of instructors who are advising more than one student.

Context: CREATE TABLE advisor (i_id VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR)

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: Find the name of the students who have more than one advisor?

Context: CREATE TABLE student (name VARCHAR, id VARCHAR); CREATE TABLE advisor (s_id VARCHAR)

SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id = T2.s_id GROUP BY T2.s_id HAVING COUNT(*) > 1


Question: Find the number of rooms with more than 50 capacity for each building.

Context: CREATE TABLE classroom (building VARCHAR, capacity INTEGER)

SELECT COUNT(*), building FROM classroom WHERE capacity > 50 GROUP BY building


Question: Find the maximum and average capacity among rooms in each building.

SELECT MAX(capacity), AVG(capacity), building FROM classroom GROUP BY building


Question: Find the title of the course that is offered by more than one department.

Context: CREATE TABLE course (title VARCHAR)

SELECT title FROM course GROUP BY title HAVING COUNT(*) > 1


Question: Find the total credits of courses provided by different department.

SELECT SUM(credits), dept_name FROM course GROUP BY dept_name


Question: Find the minimum salary for the departments whose average salary is above the average payment of all instructors.

Context: CREATE TABLE instructor (dept_name VARCHAR, salary INTEGER)

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


Question: Find the number of courses provided in each semester and year.

Context: CREATE TABLE SECTION (semester VARCHAR, YEAR VARCHAR)

SELECT COUNT(*), semester, YEAR FROM SECTION GROUP BY semester, YEAR


Question: Find the year which offers the largest number of courses.

Context: CREATE TABLE SECTION (YEAR VARCHAR)

SELECT YEAR FROM SECTION GROUP BY YEAR ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the year and semester when offers the largest number of courses.

SELECT semester, YEAR FROM SECTION GROUP BY semester, YEAR ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of department has the highest amount of students?

Context: CREATE TABLE student (dept_name VARCHAR)

SELECT dept_name FROM student GROUP BY dept_name ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the total number of students in each department.

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


Question: Find the semester and year which has the least number of student taking any class.

Context: CREATE TABLE takes (semester VARCHAR, YEAR VARCHAR)

SELECT semester, YEAR FROM takes GROUP BY semester, YEAR ORDER BY COUNT(*) LIMIT 1


Question: What is the id of the instructor who advises of all students from History department?

Context: CREATE TABLE advisor (s_id VARCHAR); CREATE TABLE student (id VARCHAR, dept_name VARCHAR)

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


Question: Find the name and salary of the instructors who are advisors of any student from History department?

Context: CREATE TABLE instructor (name VARCHAR, salary VARCHAR, id VARCHAR); CREATE TABLE advisor (i_id VARCHAR, s_id VARCHAR); CREATE TABLE student (id VARCHAR, dept_name VARCHAR)

SELECT T2.name, T2.salary FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'History'


Question: Find the id of the courses that do not have any prerequisite?

Context: CREATE TABLE prereq (course_id VARCHAR); CREATE TABLE course (course_id VARCHAR)

SELECT course_id FROM course EXCEPT SELECT course_id FROM prereq


Question: What is the title of the prerequisite class of International Finance course?

Context: CREATE TABLE course (title VARCHAR, course_id VARCHAR); CREATE TABLE prereq (prereq_id VARCHAR, course_id VARCHAR); CREATE TABLE course (course_id VARCHAR, title VARCHAR)

SELECT title FROM course WHERE course_id IN (SELECT T1.prereq_id FROM prereq AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.title = 'International Finance')


Question: Find the title of course whose prerequisite is course Differential Geometry.

Context: CREATE TABLE prereq (course_id VARCHAR, prereq_id VARCHAR); CREATE TABLE course (title VARCHAR, course_id VARCHAR); CREATE TABLE course (course_id VARCHAR, title VARCHAR)

SELECT title FROM course WHERE course_id IN (SELECT T1.course_id FROM prereq AS T1 JOIN course AS T2 ON T1.prereq_id = T2.course_id WHERE T2.title = 'Differential Geometry')


Question: Find the names of students who have taken any course in the fall semester of year 2003.

Context: CREATE TABLE student (name VARCHAR, id VARCHAR, semester VARCHAR, YEAR VARCHAR); CREATE TABLE takes (name VARCHAR, id VARCHAR, semester VARCHAR, YEAR VARCHAR)

SELECT name FROM student WHERE id IN (SELECT id FROM takes WHERE semester = 'Fall' AND YEAR = 2003)


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

Context: CREATE TABLE course (title VARCHAR, course_id VARCHAR); CREATE TABLE SECTION (course_id VARCHAR)

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: Find the name of the instructors who taught C Programming course before.

Context: CREATE TABLE teaches (id VARCHAR, course_id VARCHAR); CREATE TABLE course (course_id VARCHAR, title VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR)

SELECT T1.name FROM instructor AS T1 JOIN teaches AS T2 ON T1.id = T2.id JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.title = 'C Programming'


Question: Find the name and salary of instructors who are advisors of the students from the Math department.

SELECT T2.name, T2.salary FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'Math'


Question: Find the name of instructors who are advisors of the students from the Math department, and sort the results by students' total credit.

Context: CREATE TABLE student (id VARCHAR, dept_name VARCHAR, tot_cred VARCHAR); CREATE TABLE advisor (i_id VARCHAR, s_id VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR)

SELECT T2.name FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'Math' ORDER BY T3.tot_cred


Question: What is the course title of the prerequisite of course Mobile Computing?

SELECT title FROM course WHERE course_id IN (SELECT T1.prereq_id FROM prereq AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.title = 'Mobile Computing')


Question: Find the name of instructor who is the advisor of the student who has the highest number of total credits.

Context: CREATE TABLE student (id VARCHAR, tot_cred VARCHAR); CREATE TABLE advisor (i_id VARCHAR, s_id VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR)

SELECT T2.name FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id ORDER BY T3.tot_cred DESC LIMIT 1


Question: Find the name of instructors who didn't teach any courses?

Context: CREATE TABLE teaches (name VARCHAR, id VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR)

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


Question: Find the id of instructors who didn't teach any courses?

Context: CREATE TABLE teaches (id VARCHAR); CREATE TABLE instructor (id VARCHAR)

SELECT id FROM instructor EXCEPT SELECT id FROM teaches


Question: Find the names of instructors who didn't each any courses in any Spring semester.

Context: CREATE TABLE teaches (name VARCHAR, id VARCHAR, semester VARCHAR); CREATE TABLE instructor (name VARCHAR, id VARCHAR, semester VARCHAR)

SELECT name FROM instructor WHERE NOT id IN (SELECT id FROM teaches WHERE semester = 'Spring')


Question: Find the name of the department which has the highest average salary of professors.

Context: CREATE TABLE instructor (dept_name VARCHAR, salary INTEGER)

SELECT dept_name FROM instructor GROUP BY dept_name ORDER BY AVG(salary) DESC LIMIT 1


Question: Find the number and averaged salary of all instructors who are in the department with the highest budget.

Context: CREATE TABLE department (dept_name VARCHAR, budget VARCHAR); CREATE TABLE instructor (salary INTEGER, dept_name VARCHAR)

SELECT AVG(T1.salary), COUNT(*) FROM instructor AS T1 JOIN department AS T2 ON T1.dept_name = T2.dept_name ORDER BY T2.budget DESC LIMIT 1


Question: What is the title and credits of the course that is taught in the largest classroom (with the highest capacity)?

Context: CREATE TABLE SECTION (course_id VARCHAR, building VARCHAR, room_number VARCHAR); CREATE TABLE course (title VARCHAR, credits VARCHAR, course_id VARCHAR); CREATE TABLE classroom (capacity INTEGER, building VARCHAR, room_number VARCHAR); CREATE TABLE classroom (capacity INTEGER)

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: Find the name of students who didn't take any course from Biology department.

Context: CREATE TABLE student (name VARCHAR, id VARCHAR); CREATE TABLE course (course_id VARCHAR, dept_name VARCHAR); CREATE TABLE takes (id VARCHAR, course_id VARCHAR)

SELECT name FROM student WHERE NOT id IN (SELECT T1.id FROM takes AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.dept_name = 'Biology')


Question: Find the total number of students and total number of instructors for each department.

Context: CREATE TABLE department (dept_name VARCHAR); CREATE TABLE student (id VARCHAR, dept_name VARCHAR); CREATE TABLE instructor (dept_name VARCHAR, id VARCHAR)

SELECT COUNT(DISTINCT T2.id), COUNT(DISTINCT T3.id), T3.dept_name FROM department AS T1 JOIN student AS T2 ON T1.dept_name = T2.dept_name JOIN instructor AS T3 ON T1.dept_name = T3.dept_name GROUP BY T3.dept_name


Question: Find the name of students who have taken the prerequisite course of the course with title International Finance.

Context: CREATE TABLE student (name VARCHAR, id VARCHAR); CREATE TABLE course (course_id VARCHAR, title VARCHAR); CREATE TABLE prereq (prereq_id VARCHAR, course_id VARCHAR); CREATE TABLE takes (id VARCHAR, course_id VARCHAR)

SELECT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id = T2.id WHERE T2.course_id IN (SELECT T4.prereq_id FROM course AS T3 JOIN prereq AS T4 ON T3.course_id = T4.course_id WHERE T3.title = 'International Finance')


Question: Find the name and salary of instructors whose salary is below the average salary of the instructors in the Physics department.

Context: CREATE TABLE instructor (name VARCHAR, salary INTEGER, dept_name VARCHAR)

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


Question: Find the name of students who took some course offered by Statistics department.

Context: CREATE TABLE student (name VARCHAR, id VARCHAR); CREATE TABLE takes (course_id VARCHAR, id VARCHAR); CREATE TABLE course (course_id VARCHAR, dept_name VARCHAR)

SELECT T3.name FROM course AS T1 JOIN takes AS T2 ON T1.course_id = T2.course_id JOIN student AS T3 ON T2.id = T3.id WHERE T1.dept_name = 'Statistics'


Question: Find the building, room number, semester and year of all courses offered by Psychology department sorted by course titles.

Context: CREATE TABLE SECTION (building VARCHAR, room_number VARCHAR, semester VARCHAR, year VARCHAR, course_id VARCHAR); CREATE TABLE course (course_id VARCHAR, dept_name VARCHAR, title VARCHAR)

SELECT T2.building, T2.room_number, T2.semester, T2.year FROM course AS T1 JOIN SECTION AS T2 ON T1.course_id = T2.course_id WHERE T1.dept_name = 'Psychology' ORDER BY T1.title


Question: Find the names of all instructors in computer science department

Context: CREATE TABLE instructor (name VARCHAR, dept_name VARCHAR)

SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.'


Question: Find the names of all instructors in Comp. Sci. department with salary > 80000.

Context: CREATE TABLE instructor (name VARCHAR, dept_name VARCHAR, salary VARCHAR)

SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.' AND salary > 80000


Question: Find the names of all instructors who have taught some course and the course_id.

Context: CREATE TABLE instructor (ID VARCHAR); CREATE TABLE teaches (ID VARCHAR)

SELECT name, course_id FROM instructor AS T1 JOIN teaches AS T2 ON T1.ID = T2.ID


Question: Find the names of all instructors in the Art department who have taught some course and the course_id.

Context: CREATE TABLE instructor (ID VARCHAR, dept_name VARCHAR); CREATE TABLE teaches (ID VARCHAR)

SELECT name, course_id FROM instructor AS T1 JOIN teaches AS T2 ON T1.ID = T2.ID WHERE T1.dept_name = 'Art'


Question: Find the names of all instructors whose name includes the substring “dar”.

Context: CREATE TABLE instructor (name VARCHAR)

SELECT name FROM instructor WHERE name LIKE '%dar%'


Question: List in alphabetic order the names of all distinct instructors.

Context: CREATE TABLE instructor (name VARCHAR)

SELECT DISTINCT name FROM instructor ORDER BY name


Question: Find courses that ran in Fall 2009 or in Spring 2010.

Context: CREATE TABLE SECTION (course_id VARCHAR, semester VARCHAR, YEAR VARCHAR)

SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 UNION SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010


Question: Find courses that ran in Fall 2009 and in Spring 2010.

SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 INTERSECT SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010


Question: Find courses that ran in Fall 2009 but not in Spring 2010.

SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010


Question: Find the salaries of all distinct instructors that are less than the largest salary.

Context: CREATE TABLE instructor (salary INTEGER)

SELECT DISTINCT salary FROM instructor WHERE salary < (SELECT MAX(salary) FROM instructor)


Question: Find the total number of instructors who teach a course in the Spring 2010 semester.

Context: CREATE TABLE teaches (ID VARCHAR, semester VARCHAR, YEAR VARCHAR)

SELECT COUNT(DISTINCT ID) FROM teaches WHERE semester = 'Spring' AND YEAR = 2010


Question: Find the names and average salaries of all departments whose average salary is greater than 42000.

SELECT dept_name, AVG(salary) FROM instructor GROUP BY dept_name HAVING AVG(salary) > 42000


Question: Find names of instructors with salary greater than that of some (at least one) instructor in the Biology department.

SELECT name FROM instructor WHERE salary > (SELECT MIN(salary) FROM instructor WHERE dept_name = 'Biology')


Question: Find the names of all instructors whose salary is greater than the salary of all instructors in the Biology department.

SELECT name FROM instructor WHERE salary > (SELECT MAX(salary) FROM instructor WHERE dept_name = 'Biology')


Question: How many debates are there?

Context: CREATE TABLE debate (Id VARCHAR)


Question: List the venues of debates in ascending order of the number of audience.

Context: CREATE TABLE debate (Venue VARCHAR, Num_of_Audience VARCHAR)

SELECT Venue FROM debate ORDER BY Num_of_Audience


Question: What are the date and venue of each debate?

Context: CREATE TABLE debate (Date VARCHAR, Venue VARCHAR)


Question: List the dates of debates with number of audience bigger than 150

Context: CREATE TABLE debate (Date VARCHAR, Num_of_Audience INTEGER)

SELECT Date FROM debate WHERE Num_of_Audience > 150


Question: Show the names of people aged either 35 or 36.

Context: CREATE TABLE people (Name VARCHAR, Age VARCHAR)

SELECT Name FROM people WHERE Age = 35 OR Age = 36


Question: What is the party of the youngest people?

Context: CREATE TABLE people (Party VARCHAR, Age VARCHAR)

SELECT Party FROM people ORDER BY Age LIMIT 1


Question: Show different parties of people along with the number of people in each party.

Context: CREATE TABLE people (Party VARCHAR)

SELECT Party, COUNT(*) FROM people GROUP BY Party


Question: Show the party that has the most people.

Context: CREATE TABLE people (Party VARCHAR)

SELECT Party FROM people GROUP BY Party ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the distinct venues of debates

Context: CREATE TABLE debate (Venue VARCHAR)


Question: Show the names of people, and dates and venues of debates they are on the affirmative side.

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE debate (Date VARCHAR, Venue VARCHAR, Debate_ID VARCHAR); CREATE TABLE debate_people (Debate_ID VARCHAR, Affirmative VARCHAR)

SELECT T3.Name, T2.Date, T2.Venue FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Affirmative = T3.People_ID


Question: Show the names of people, and dates and venues of debates they are on the negative side, ordered in ascending alphabetical order of name.

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE debate (Date VARCHAR, Venue VARCHAR, Debate_ID VARCHAR); CREATE TABLE debate_people (Debate_ID VARCHAR, Negative VARCHAR)

SELECT T3.Name, T2.Date, T2.Venue FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Negative = T3.People_ID ORDER BY T3.Name


Question: Show the names of people that are on affirmative side of debates with number of audience bigger than 200.

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE debate (Debate_ID VARCHAR, Num_of_Audience INTEGER); CREATE TABLE debate_people (Debate_ID VARCHAR, Affirmative VARCHAR)

SELECT T3.Name FROM debate_people AS T1 JOIN debate AS T2 ON T1.Debate_ID = T2.Debate_ID JOIN people AS T3 ON T1.Affirmative = T3.People_ID WHERE T2.Num_of_Audience > 200


Question: Show the names of people and the number of times they have been on the affirmative side of debates.

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE debate_people (Affirmative VARCHAR)

SELECT T2.Name, COUNT(*) FROM debate_people AS T1 JOIN people AS T2 ON T1.Affirmative = T2.People_ID GROUP BY T2.Name


Question: Show the names of people who have been on the negative side of debates at least twice.

Context: CREATE TABLE debate_people (Negative VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T2.Name FROM debate_people AS T1 JOIN people AS T2 ON T1.Negative = T2.People_ID GROUP BY T2.Name HAVING COUNT(*) >= 2


Question: List the names of people that have not been on the affirmative side of debates.

Context: CREATE TABLE debate_people (Name VARCHAR, People_id VARCHAR, Affirmative VARCHAR); CREATE TABLE people (Name VARCHAR, People_id VARCHAR, Affirmative VARCHAR)

SELECT Name FROM people WHERE NOT People_id IN (SELECT Affirmative FROM debate_people)


Question: List the names of all the customers in alphabetical order.

Context: CREATE TABLE customers (customer_details VARCHAR)

SELECT customer_details FROM customers ORDER BY customer_details


Question: Find all the policy type codes associated with the customer "Dayana Robel"

Context: CREATE TABLE customers (customer_id VARCHAR, customer_details VARCHAR); CREATE TABLE policies (customer_id VARCHAR)

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: Which type of policy is most frequently used? Give me the policy type code.

Context: CREATE TABLE policies (policy_type_code VARCHAR)

SELECT policy_type_code FROM policies GROUP BY policy_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Find all the policy types that are used by more than 2 customers.

SELECT policy_type_code FROM policies GROUP BY policy_type_code HAVING COUNT(*) > 2


Question: Find the total and average amount paid in claim headers.

Context: CREATE TABLE claim_headers (amount_piad INTEGER)

SELECT SUM(amount_piad), AVG(amount_piad) FROM claim_headers


Question: Find the total amount claimed in the most recently created document.

Context: CREATE TABLE claim_headers (amount_claimed INTEGER, claim_header_id VARCHAR); CREATE TABLE claims_documents (claim_id VARCHAR, created_date VARCHAR); CREATE TABLE claims_documents (created_date VARCHAR)

SELECT SUM(t1.amount_claimed) FROM claim_headers AS t1 JOIN claims_documents AS t2 ON t1.claim_header_id = t2.claim_id WHERE t2.created_date = (SELECT created_date FROM claims_documents ORDER BY created_date LIMIT 1)


Question: What is the name of the customer who has made the largest amount of claim in a single claim?

Context: CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE claim_headers (amount_claimed INTEGER); CREATE TABLE policies (policy_id VARCHAR, customer_id VARCHAR); CREATE TABLE claim_headers (policy_id VARCHAR, amount_claimed INTEGER)

SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_claimed = (SELECT MAX(amount_claimed) FROM claim_headers)


Question: What is the name of the customer who has made the minimum amount of payment in one claim?

Context: CREATE TABLE claim_headers (amount_piad INTEGER); CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE policies (policy_id VARCHAR, customer_id VARCHAR); CREATE TABLE claim_headers (policy_id VARCHAR, amount_piad INTEGER)

SELECT t3.customer_details FROM claim_headers AS t1 JOIN policies AS t2 ON t1.policy_id = t2.policy_id JOIN customers AS t3 ON t2.customer_id = t3.customer_id WHERE t1.amount_piad = (SELECT MIN(amount_piad) FROM claim_headers)


Question: Find the names of customers who have no policies associated.

Context: CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE customers (customer_details VARCHAR); CREATE TABLE policies (customer_id VARCHAR)

SELECT customer_details FROM customers EXCEPT SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id


Question: How many claim processing stages are there in total?

Context: CREATE TABLE claims_processing_stages (Id VARCHAR)

SELECT COUNT(*) FROM claims_processing_stages


Question: What is the name of the claim processing stage that most of the claims are on?

Context: CREATE TABLE claims_processing (claim_stage_id VARCHAR); CREATE TABLE claims_processing_stages (claim_status_name VARCHAR, claim_stage_id VARCHAR)

SELECT t2.claim_status_name FROM claims_processing AS t1 JOIN claims_processing_stages AS t2 ON t1.claim_stage_id = t2.claim_stage_id GROUP BY t1.claim_stage_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the names of customers whose name contains "Diana".

SELECT customer_details FROM customers WHERE customer_details LIKE "%Diana%"


Question: Find the names of the customers who have an deputy policy.

Context: CREATE TABLE policies (customer_id VARCHAR, policy_type_code VARCHAR); CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR)

SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = "Deputy"


Question: Find the names of customers who either have an deputy policy or uniformed policy.

SELECT DISTINCT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.policy_type_code = "Deputy" OR t1.policy_type_code = "Uniform"


Question: Find the names of all the customers and staff members.

Context: CREATE TABLE staff (customer_details VARCHAR, staff_details VARCHAR); CREATE TABLE customers (customer_details VARCHAR, staff_details VARCHAR)

SELECT customer_details FROM customers UNION SELECT staff_details FROM staff


Question: Find the number of records of each policy type and its type code.

SELECT policy_type_code, COUNT(*) FROM policies GROUP BY policy_type_code


Question: Find the name of the customer that has been involved in the most policies.

Context: CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE policies (customer_id VARCHAR)

SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id GROUP BY t2.customer_details ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the description of the claim status "Open"?

Context: CREATE TABLE claims_processing_stages (claim_status_description VARCHAR, claim_status_name VARCHAR)

SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = "Open"


Question: How many distinct claim outcome codes are there?

Context: CREATE TABLE claims_processing (claim_outcome_code VARCHAR)

SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing


Question: Which customer is associated with the latest policy?

Context: CREATE TABLE customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE policies (start_date INTEGER); CREATE TABLE policies (customer_id VARCHAR, start_date INTEGER)

SELECT t2.customer_details FROM policies AS t1 JOIN customers AS t2 ON t1.customer_id = t2.customer_id WHERE t1.start_date = (SELECT MAX(start_date) FROM policies)


Question: Show the id, the date of account opened, the account name, and other account detail for all accounts.

Context: CREATE TABLE Accounts (account_id VARCHAR, date_account_opened VARCHAR, account_name VARCHAR, other_account_details VARCHAR)

SELECT account_id, date_account_opened, account_name, other_account_details FROM Accounts


Question: Show the id, the account name, and other account details for all accounts by the customer with first name 'Meaghan'.

Context: CREATE TABLE Accounts (account_id VARCHAR, date_account_opened VARCHAR, account_name VARCHAR, other_account_details VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR)

SELECT T1.account_id, T1.date_account_opened, T1.account_name, T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan'


Question: Show the account name and other account detail for all accounts by the customer with first name Meaghan and last name Keeling.

Context: CREATE TABLE Customers (customer_id VARCHAR, customer_first_name VARCHAR, customer_last_name VARCHAR); CREATE TABLE Accounts (account_name VARCHAR, other_account_details VARCHAR, customer_id VARCHAR)

SELECT T1.account_name, T1.other_account_details FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Meaghan" AND T2.customer_last_name = "Keeling"


Question: Show the first name and last name for the customer with account name 900.

Context: CREATE TABLE Accounts (customer_id VARCHAR, account_name VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR)

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: Show the unique first names, last names, and phone numbers for all customers with any account.

Context: CREATE TABLE Accounts (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, phone_number VARCHAR, customer_id VARCHAR)

SELECT DISTINCT T1.customer_first_name, T1.customer_last_name, T1.phone_number FROM Customers AS T1 JOIN Accounts AS T2 ON T1.customer_id = T2.customer_id


Question: Show customer ids who don't have an account.

Context: CREATE TABLE Customers (customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR)

SELECT customer_id FROM Customers EXCEPT SELECT customer_id FROM Accounts


Question: How many accounts does each customer have? List the number and customer id.

Context: CREATE TABLE Accounts (customer_id VARCHAR)

SELECT COUNT(*), customer_id FROM Accounts GROUP BY customer_id


Question: What is the customer id, first and last name with most number of accounts.

Context: CREATE TABLE Accounts (customer_id VARCHAR); CREATE TABLE Customers (customer_first_name VARCHAR, customer_last_name VARCHAR, customer_id VARCHAR)

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


Question: Show id, first name and last name for all customers and the number of accounts.

SELECT T1.customer_id, T2.customer_first_name, T2.customer_last_name, COUNT(*) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id


Question: Show first name and id for all customers with at least 2 accounts.

Context: CREATE TABLE Customers (customer_first_name VARCHAR, customer_id VARCHAR); CREATE TABLE Accounts (customer_id VARCHAR)

SELECT T2.customer_first_name, T1.customer_id FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2


Question: Show the number of customers for each gender.

Context: CREATE TABLE Customers (gender VARCHAR)

SELECT gender, COUNT(*) FROM Customers GROUP BY gender


Question: How many transactions do we have?

Context: CREATE TABLE Financial_transactions (Id VARCHAR)

SELECT COUNT(*) FROM Financial_transactions


Question: How many transaction does each account have? Show the number and account id.

Context: CREATE TABLE Financial_transactions (account_id VARCHAR)

SELECT COUNT(*), account_id FROM Financial_transactions


Question: How many transaction does account with name 337 have?

Context: CREATE TABLE Accounts (account_id VARCHAR, account_name VARCHAR); CREATE TABLE Financial_transactions (account_id VARCHAR)

SELECT COUNT(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id WHERE T2.account_name = "337"


Question: What is the average, minimum, maximum, and total transaction amount?

Context: CREATE TABLE Financial_transactions (transaction_amount INTEGER)

SELECT AVG(transaction_amount), MIN(transaction_amount), MAX(transaction_amount), SUM(transaction_amount) FROM Financial_transactions


Question: Show ids for all transactions whose amounts are greater than the average.

Context: CREATE TABLE Financial_transactions (transaction_id VARCHAR, transaction_amount INTEGER)

SELECT transaction_id FROM Financial_transactions WHERE transaction_amount > (SELECT AVG(transaction_amount) FROM Financial_transactions)


Question: Show the transaction types and the total amount of transactions.

Context: CREATE TABLE Financial_transactions (transaction_type VARCHAR, transaction_amount INTEGER)

SELECT transaction_type, SUM(transaction_amount) FROM Financial_transactions GROUP BY transaction_type


Question: Show the account name, id and the number of transactions for each account.

Context: CREATE TABLE Financial_transactions (account_id VARCHAR); CREATE TABLE Accounts (account_name VARCHAR, account_id VARCHAR)

SELECT T2.account_name, T1.account_id, COUNT(*) FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id


Question: Show the account id with most number of transactions.

SELECT account_id FROM Financial_transactions GROUP BY account_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the account id and name with at least 4 transactions.

SELECT T1.account_id, T2.account_name FROM Financial_transactions AS T1 JOIN Accounts AS T2 ON T1.account_id = T2.account_id GROUP BY T1.account_id HAVING COUNT(*) >= 4


Question: Show all product sizes.

Context: CREATE TABLE Products (product_size VARCHAR)

SELECT DISTINCT product_size FROM Products


Question: Show all product colors.

Context: CREATE TABLE Products (product_color VARCHAR)

SELECT DISTINCT product_color FROM Products


Question: Show the invoice number and the number of transactions for each invoice.

Context: CREATE TABLE Financial_transactions (invoice_number VARCHAR)

SELECT invoice_number, COUNT(*) FROM Financial_transactions GROUP BY invoice_number


Question: What is the invoice number and invoice date for the invoice with most number of transactions?

Context: CREATE TABLE Invoices (invoice_number VARCHAR, invoice_date VARCHAR); CREATE TABLE Financial_transactions (invoice_number VARCHAR)

SELECT T2.invoice_number, T2.invoice_date FROM Financial_transactions AS T1 JOIN Invoices AS T2 ON T1.invoice_number = T2.invoice_number GROUP BY T1.invoice_number ORDER BY COUNT(*) DESC LIMIT 1


Question: How many invoices do we have?

Context: CREATE TABLE Invoices (Id VARCHAR)


Question: Show invoice dates and order id and details for all invoices.

Context: CREATE TABLE Invoices (invoice_date VARCHAR, order_id VARCHAR); CREATE TABLE Orders (order_details VARCHAR, order_id VARCHAR)

SELECT T1.invoice_date, T1.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id


Question: Show the order ids and the number of invoices for each order.

Context: CREATE TABLE Invoices (order_id VARCHAR)

SELECT order_id, COUNT(*) FROM Invoices GROUP BY order_id


Question: What is the order id and order details for the order more than two invoices.

Context: CREATE TABLE Orders (order_id VARCHAR, order_details VARCHAR); CREATE TABLE Invoices (order_id VARCHAR)

SELECT T2.order_id, T2.order_details FROM Invoices AS T1 JOIN Orders AS T2 ON T1.order_id = T2.order_id GROUP BY T2.order_id HAVING COUNT(*) > 2


Question: What is the customer last name, id and phone number with most number of orders?

Context: CREATE TABLE Orders (customer_id VARCHAR); CREATE TABLE Customers (customer_last_name VARCHAR, phone_number VARCHAR, customer_id VARCHAR)

SELECT T2.customer_last_name, T1.customer_id, T2.phone_number FROM Orders AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all product names without an order.

Context: CREATE TABLE Products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE Order_items (product_id VARCHAR); CREATE TABLE Products (product_name VARCHAR)

SELECT product_name FROM Products EXCEPT SELECT T1.product_name FROM Products AS T1 JOIN Order_items AS T2 ON T1.product_id = T2.product_id


Question: Show all product names and the total quantity ordered for each product name.

Context: CREATE TABLE Products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE Order_items (product_quantity INTEGER, product_id VARCHAR)

SELECT T2.product_name, SUM(T1.product_quantity) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name


Question: Show the order ids and the number of items in each order.

Context: CREATE TABLE Order_items (order_id VARCHAR)

SELECT order_id, COUNT(*) FROM Order_items GROUP BY order_id


Question: Show the product ids and the number of unique orders containing each product.

Context: CREATE TABLE Order_items (product_id VARCHAR, order_id VARCHAR)

SELECT product_id, COUNT(DISTINCT order_id) FROM Order_items GROUP BY product_id


Question: Show all product names and the number of customers having an order on each product.

Context: CREATE TABLE Order_items (product_id VARCHAR, order_id VARCHAR); CREATE TABLE Orders (order_id VARCHAR); CREATE TABLE Products (product_name VARCHAR, product_id VARCHAR)

SELECT T2.product_name, COUNT(*) FROM Order_items AS T1 JOIN Products AS T2 ON T1.product_id = T2.product_id JOIN Orders AS T3 ON T3.order_id = T1.order_id GROUP BY T2.product_name


Question: Show order ids and the number of products in each order.

Context: CREATE TABLE Order_items (order_id VARCHAR, product_id VARCHAR)

SELECT order_id, COUNT(DISTINCT product_id) FROM Order_items GROUP BY order_id


Question: Show order ids and the total quantity in each order.

Context: CREATE TABLE Order_items (order_id VARCHAR, product_quantity INTEGER)

SELECT order_id, SUM(product_quantity) FROM Order_items GROUP BY order_id


Question: How many products were not included in any order?

Context: CREATE TABLE products (product_id VARCHAR); CREATE TABLE Order_items (product_id VARCHAR)

SELECT COUNT(*) FROM products WHERE NOT product_id IN (SELECT product_id FROM Order_items)


Question: How many churches opened before 1850 are there?

Context: CREATE TABLE Church (Open_Date INTEGER)

SELECT COUNT(*) FROM Church WHERE Open_Date < 1850


Question: Show the name, open date, and organizer for all churches.

Context: CREATE TABLE Church (name VARCHAR, open_date VARCHAR, organized_by VARCHAR)

SELECT name, open_date, organized_by FROM Church


Question: List all church names in descending order of opening date.

Context: CREATE TABLE church (name VARCHAR, open_date VARCHAR)

SELECT name FROM church ORDER BY open_date DESC


Question: Show the opening year in whcih at least two churches opened.

Context: CREATE TABLE church (open_date VARCHAR)

SELECT open_date FROM church GROUP BY open_date HAVING COUNT(*) >= 2


Question: Show the organizer and name for churches that opened between 1830 and 1840.

Context: CREATE TABLE church (organized_by VARCHAR, name VARCHAR, open_date INTEGER)

SELECT organized_by, name FROM church WHERE open_date BETWEEN 1830 AND 1840


Question: Show all opening years and the number of churches that opened in that year.

Context: CREATE TABLE church (open_date VARCHAR)

SELECT open_date, COUNT(*) FROM church GROUP BY open_date


Question: Show the name and opening year for three churches that opened most recently.

SELECT name, open_date FROM church ORDER BY open_date DESC LIMIT 3


Question: How many female people are older than 30 in our record?

Context: CREATE TABLE people (is_male VARCHAR, age VARCHAR)

SELECT COUNT(*) FROM people WHERE is_male = 'F' AND age > 30


Question: Show the country where people older than 30 and younger than 25 are from.

Context: CREATE TABLE people (country VARCHAR, age INTEGER)

SELECT country FROM people WHERE age < 25 INTERSECT SELECT country FROM people WHERE age > 30


Question: Show the minimum, maximum, and average age for all people.

Context: CREATE TABLE people (age INTEGER)

SELECT MIN(age), MAX(age), AVG(age) FROM people


Question: Show the name and country for all people whose age is smaller than the average.

Context: CREATE TABLE people (name VARCHAR, country VARCHAR, age INTEGER)

SELECT name, country FROM people WHERE age < (SELECT AVG(age) FROM people)


Question: Show the pair of male and female names in all weddings after year 2014

Context: CREATE TABLE wedding (male_id VARCHAR, female_id VARCHAR, year INTEGER); CREATE TABLE people (name VARCHAR, people_id VARCHAR)

SELECT T2.name, T3.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id WHERE T1.year > 2014


Question: Show the name and age for all male people who don't have a wedding.

Context: CREATE TABLE wedding (name VARCHAR, age VARCHAR, is_male VARCHAR, people_id VARCHAR, male_id VARCHAR); CREATE TABLE people (name VARCHAR, age VARCHAR, is_male VARCHAR, people_id VARCHAR, male_id VARCHAR)

SELECT name, age FROM people WHERE is_male = 'T' AND NOT people_id IN (SELECT male_id FROM wedding)


Question: Show all church names except for those that had a wedding in year 2015.

Context: CREATE TABLE church (name VARCHAR); CREATE TABLE wedding (church_id VARCHAR, year VARCHAR); CREATE TABLE church (name VARCHAR, church_id VARCHAR)

SELECT name FROM church EXCEPT SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id WHERE T2.year = 2015


Question: Show all church names that have hosted least two weddings.

Context: CREATE TABLE wedding (church_id VARCHAR); CREATE TABLE church (name VARCHAR, church_id VARCHAR)

SELECT T1.name FROM church AS T1 JOIN wedding AS T2 ON T1.church_id = T2.church_id GROUP BY T1.church_id HAVING COUNT(*) >= 2


Question: Show the names for all females from Canada having a wedding in year 2016.

Context: CREATE TABLE people (name VARCHAR, people_id VARCHAR, country VARCHAR, is_male VARCHAR); CREATE TABLE wedding (female_id VARCHAR, year VARCHAR)

SELECT T2.name FROM wedding AS T1 JOIN people AS T2 ON T1.female_id = T2.people_id WHERE T1.year = 2016 AND T2.is_male = 'F' AND T2.country = 'Canada'


Question: How many weddings are there in year 2016?

Context: CREATE TABLE wedding (YEAR VARCHAR)

SELECT COUNT(*) FROM wedding WHERE YEAR = 2016


Question: Show the church names for the weddings of all people older than 30.

Context: CREATE TABLE church (name VARCHAR, church_id VARCHAR); CREATE TABLE people (people_id VARCHAR, age VARCHAR); CREATE TABLE wedding (male_id VARCHAR, female_id VARCHAR, church_id VARCHAR)

SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30


Question: Show all countries and the number of people from each country.

Context: CREATE TABLE people (country VARCHAR)

SELECT country, COUNT(*) FROM people GROUP BY country


Question: How many churches have a wedding in year 2016?

Context: CREATE TABLE wedding (church_id VARCHAR, YEAR VARCHAR)

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


Question: How many artists do we have?

Context: CREATE TABLE artist (Id VARCHAR)


Question: Show all artist name, age, and country ordered by the yeared they joined.

Context: CREATE TABLE artist (name VARCHAR, age VARCHAR, country VARCHAR, Year_Join VARCHAR)

SELECT name, age, country FROM artist ORDER BY Year_Join


Question: What are all distinct country for artists?

Context: CREATE TABLE artist (country VARCHAR)


Question: Show all artist names and the year joined who are not from United States.

Context: CREATE TABLE artist (name VARCHAR, year_join VARCHAR, country VARCHAR)

SELECT name, year_join FROM artist WHERE country <> 'United States'


Question: How many artists are above age 46 and joined after 1990?

Context: CREATE TABLE artist (age VARCHAR, year_join VARCHAR)

SELECT COUNT(*) FROM artist WHERE age > 46 AND year_join > 1990


Question: What is the average and minimum age of all artists from United States.

Context: CREATE TABLE artist (age INTEGER, country VARCHAR)

SELECT AVG(age), MIN(age) FROM artist WHERE country = 'United States'


Question: What is the name of the artist who joined latest?

Context: CREATE TABLE artist (name VARCHAR, year_join VARCHAR)

SELECT name FROM artist ORDER BY year_join DESC LIMIT 1


Question: How many exhibition are there in year 2005 or after?

Context: CREATE TABLE exhibition (YEAR VARCHAR)

SELECT COUNT(*) FROM exhibition WHERE YEAR >= 2005


Question: Show theme and year for all exhibitions with ticket prices lower than 15.

Context: CREATE TABLE exhibition (theme VARCHAR, YEAR VARCHAR, ticket_price INTEGER)

SELECT theme, YEAR FROM exhibition WHERE ticket_price < 15


Question: Show all artist names and the number of exhibitions for each artist.

Context: CREATE TABLE artist (name VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition (artist_id VARCHAR)

SELECT T2.name, COUNT(*) FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id


Question: What is the name and country for the artist with most number of exhibitions?

Context: CREATE TABLE exhibition (artist_id VARCHAR); CREATE TABLE artist (name VARCHAR, country VARCHAR, artist_id VARCHAR)

SELECT T2.name, T2.country FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id GROUP BY T1.artist_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show names for artists without any exhibition.

Context: CREATE TABLE artist (name VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition (name VARCHAR, artist_id VARCHAR)

SELECT name FROM artist WHERE NOT artist_id IN (SELECT artist_id FROM exhibition)


Question: What is the theme and artist name for the exhibition with a ticket price higher than the average?

Context: CREATE TABLE exhibition (ticket_price INTEGER); CREATE TABLE exhibition (theme VARCHAR, artist_id VARCHAR, ticket_price INTEGER); CREATE TABLE artist (name VARCHAR, artist_id VARCHAR)

SELECT T1.theme, T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.ticket_price > (SELECT AVG(ticket_price) FROM exhibition)


Question: Show the average, minimum, and maximum ticket prices for exhibitions for all years before 2009.

Context: CREATE TABLE exhibition (ticket_price INTEGER, YEAR INTEGER)

SELECT AVG(ticket_price), MIN(ticket_price), MAX(ticket_price) FROM exhibition WHERE YEAR < 2009


Question: Show theme and year for all exhibitions in an descending order of ticket price.

Context: CREATE TABLE exhibition (theme VARCHAR, YEAR VARCHAR, ticket_price VARCHAR)

SELECT theme, YEAR FROM exhibition ORDER BY ticket_price DESC


Question: What is the theme, date, and attendance for the exhibition in year 2004?

Context: CREATE TABLE exhibition_record (date VARCHAR, attendance VARCHAR, exhibition_id VARCHAR); CREATE TABLE exhibition (theme VARCHAR, exhibition_id VARCHAR, year VARCHAR)

SELECT T2.theme, T1.date, T1.attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T2.year = 2004


Question: Show all artist names who didn't have an exhibition in 2004.

Context: CREATE TABLE exhibition (artist_id VARCHAR, year VARCHAR); CREATE TABLE artist (name VARCHAR); CREATE TABLE artist (name VARCHAR, artist_id VARCHAR)

SELECT name FROM artist EXCEPT SELECT T2.name FROM exhibition AS T1 JOIN artist AS T2 ON T1.artist_id = T2.artist_id WHERE T1.year = 2004


Question: Show the theme for exhibitions with both records of an attendance below 100 and above 500.

Context: CREATE TABLE exhibition (theme VARCHAR, exhibition_id VARCHAR); CREATE TABLE exhibition_record (exhibition_id VARCHAR, attendance INTEGER)

SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance < 100 INTERSECT SELECT T2.theme FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 500


Question: How many exhibitions have a attendance more than 100 or have a ticket price below 10?

Context: CREATE TABLE exhibition_record (exhibition_id VARCHAR, attendance VARCHAR); CREATE TABLE exhibition (exhibition_id VARCHAR, ticket_price VARCHAR)

SELECT COUNT(*) FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id WHERE T1.attendance > 100 OR T2.ticket_price < 10


Question: Show all artist names with an average exhibition attendance over 200.

Context: CREATE TABLE artist (name VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition (exhibition_id VARCHAR, artist_id VARCHAR); CREATE TABLE exhibition_record (exhibition_id VARCHAR, attendance INTEGER)

SELECT T3.name FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.exhibition_id = T2.exhibition_id JOIN artist AS T3 ON T3.artist_id = T2.artist_id GROUP BY T3.artist_id HAVING AVG(T1.attendance) > 200


Question: Find the id of the item whose title is "orange".

Context: CREATE TABLE item (i_id VARCHAR, title VARCHAR)

SELECT i_id FROM item WHERE title = "orange"


Question: List all information in the item table.

Context: CREATE TABLE item (Id VARCHAR)


Question: Find the number of reviews.

Context: CREATE TABLE review (Id VARCHAR)


Question: How many users are there?

Context: CREATE TABLE useracct (Id VARCHAR)


Question: Find the average and maximum rating of all reviews.

Context: CREATE TABLE review (rating INTEGER)

SELECT AVG(rating), MAX(rating) FROM review


Question: Find the highest rank of all reviews.

Context: CREATE TABLE review (rank INTEGER)


Question: How many different users wrote some reviews?

Context: CREATE TABLE review (u_id VARCHAR)


Question: How many different items were reviewed by some users?

Context: CREATE TABLE review (i_id VARCHAR)


Question: Find the number of items that did not receive any review.

Context: CREATE TABLE review (i_id VARCHAR); CREATE TABLE item (i_id VARCHAR)

SELECT COUNT(*) FROM item WHERE NOT i_id IN (SELECT i_id FROM review)


Question: Find the names of users who did not leave any review.

Context: CREATE TABLE review (name VARCHAR, u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR)

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


Question: Find the names of goods that receive a rating of 10.

Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating VARCHAR)

SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating = 10


Question: Find the titles of items whose rating is higher than the average review rating of all items.

Context: CREATE TABLE review (rating INTEGER); CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER)

SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > (SELECT AVG(rating) FROM review)


Question: Find the titles of items that received any rating below 5.

Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rating INTEGER)

SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5


Question: Find the titles of items that received both a rating higher than 8 and a rating below 5.

SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > 8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5


Question: Find the names of items whose rank is higher than 3 and whose average rating is above 5.

Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (i_id VARCHAR, rank INTEGER, rating INTEGER)

SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rank > 3 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id HAVING AVG(T2.rating) > 5


Question: Find the name of the item with the lowest average rating.

SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rating) LIMIT 1


Question: List the titles of all items in alphabetic order .

Context: CREATE TABLE item (title VARCHAR)


Question: Find the name of the user who gives the most reviews.

Context: CREATE TABLE useracct (name VARCHAR, u_id VARCHAR); CREATE TABLE review (u_id VARCHAR)

SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name and id of the item with the highest average rating.

SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rating) DESC LIMIT 1


Question: Find the name and id of the good with the highest average rank.

Context: CREATE TABLE review (i_id VARCHAR, rank INTEGER); CREATE TABLE item (title VARCHAR, i_id VARCHAR)

SELECT T1.title, T1.i_id FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id GROUP BY T2.i_id ORDER BY AVG(T2.rank) DESC LIMIT 1


Question: For each user, return the name and the average rating of reviews given by them.

Context: CREATE TABLE review (rating INTEGER, u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR)

SELECT T1.name, AVG(T2.rating) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id


Question: For each user, find their name and the number of reviews written by them.

SELECT T1.name, COUNT(*) FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id


Question: Find the name of the user who gave the highest rating.

Context: CREATE TABLE review (u_id VARCHAR, rating VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR)

SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id ORDER BY T2.rating DESC LIMIT 1


Question: Find the name of the source user with the highest average trust score.

Context: CREATE TABLE useracct (name VARCHAR, u_id VARCHAR); CREATE TABLE trust (source_u_id VARCHAR)

SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.source_u_id GROUP BY T2.source_u_id ORDER BY AVG(trust) DESC LIMIT 1


Question: Find each target user's name and average trust score.

Context: CREATE TABLE trust (target_u_id VARCHAR); CREATE TABLE useracct (name VARCHAR, u_id VARCHAR)

SELECT T1.name, AVG(trust) FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id GROUP BY T2.target_u_id


Question: Find the name of the target user with the lowest trust score.

SELECT T1.name FROM useracct AS T1 JOIN trust AS T2 ON T1.u_id = T2.target_u_id ORDER BY trust LIMIT 1


Question: Find the names of the items that did not receive any review.

Context: CREATE TABLE item (title VARCHAR, i_id VARCHAR); CREATE TABLE review (title VARCHAR, i_id VARCHAR)

SELECT title FROM item WHERE NOT i_id IN (SELECT i_id FROM review)


Question: Find the number of users who did not write any review.

Context: CREATE TABLE review (u_id VARCHAR); CREATE TABLE useracct (u_id VARCHAR)

SELECT COUNT(*) FROM useracct WHERE NOT u_id IN (SELECT u_id FROM review)


Question: How many players are there?

Context: CREATE TABLE player (Id VARCHAR)


Question: List the names of players in ascending order of votes.

Context: CREATE TABLE player (Player_name VARCHAR, Votes VARCHAR)

SELECT Player_name FROM player ORDER BY Votes


Question: What are the gender and occupation of players?

Context: CREATE TABLE player (Gender VARCHAR, Occupation VARCHAR)


Question: List the name and residence for players whose occupation is not "Researcher".

Context: CREATE TABLE player (Player_name VARCHAR, residence VARCHAR, Occupation VARCHAR)

SELECT Player_name, residence FROM player WHERE Occupation <> "Researcher"


Question: Show the names of sponsors of players whose residence is either "Brandon" or "Birtle".

Context: CREATE TABLE player (Sponsor_name VARCHAR, Residence VARCHAR)

SELECT Sponsor_name FROM player WHERE Residence = "Brandon" OR Residence = "Birtle"


Question: What is the name of the player with the largest number of votes?

SELECT Player_name FROM player ORDER BY Votes DESC LIMIT 1


Question: Show different occupations along with the number of players in each occupation.

Context: CREATE TABLE player (Occupation VARCHAR)

SELECT Occupation, COUNT(*) FROM player GROUP BY Occupation


Question: Please show the most common occupation of players.

SELECT Occupation FROM player GROUP BY Occupation ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the residences that have at least two players.

Context: CREATE TABLE player (Residence VARCHAR)

SELECT Residence FROM player GROUP BY Residence HAVING COUNT(*) >= 2


Question: Show the names of players and names of their coaches.

Context: CREATE TABLE player (Player_name VARCHAR, Player_ID VARCHAR); CREATE TABLE coach (coach_name VARCHAR, Coach_ID VARCHAR); CREATE TABLE player_coach (Coach_ID VARCHAR, Player_ID VARCHAR)

SELECT T3.Player_name, T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID


Question: Show the names of players coached by the rank 1 coach.

Context: CREATE TABLE player (Player_name VARCHAR, Player_ID VARCHAR); CREATE TABLE coach (Coach_ID VARCHAR, Rank VARCHAR); CREATE TABLE player_coach (Coach_ID VARCHAR, Player_ID VARCHAR)

SELECT T3.Player_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T2.Rank = 1


Question: Show the names and genders of players with a coach starting after 2011.

Context: CREATE TABLE player (Player_name VARCHAR, gender VARCHAR, Player_ID VARCHAR); CREATE TABLE player_coach (Coach_ID VARCHAR, Player_ID VARCHAR, Starting_year INTEGER); CREATE TABLE coach (Coach_ID VARCHAR)

SELECT T3.Player_name, T3.gender FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID WHERE T1.Starting_year > 2011


Question: Show the names of players and names of their coaches in descending order of the votes of players.

Context: CREATE TABLE coach (coach_name VARCHAR, Coach_ID VARCHAR); CREATE TABLE player_coach (Coach_ID VARCHAR, Player_ID VARCHAR); CREATE TABLE player (Player_name VARCHAR, Player_ID VARCHAR, Votes VARCHAR)

SELECT T3.Player_name, T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.Coach_ID = T2.Coach_ID JOIN player AS T3 ON T1.Player_ID = T3.Player_ID ORDER BY T3.Votes DESC


Question: List the names of players that do not have coaches.

Context: CREATE TABLE player (Player_name VARCHAR, Player_ID VARCHAR); CREATE TABLE player_coach (Player_name VARCHAR, Player_ID VARCHAR)

SELECT Player_name FROM player WHERE NOT Player_ID IN (SELECT Player_ID FROM player_coach)


Question: Show the residences that have both a player of gender "M" and a player of gender "F".

Context: CREATE TABLE player (Residence VARCHAR, gender VARCHAR)

SELECT Residence FROM player WHERE gender = "M" INTERSECT SELECT Residence FROM player WHERE gender = "F"


Question: How many coaches does each club has? List the club id, name and the number of coaches.

Context: CREATE TABLE club (club_id VARCHAR, club_name VARCHAR); CREATE TABLE coach (club_id VARCHAR)

SELECT T1.club_id, T1.club_name, COUNT(*) FROM club AS T1 JOIN coach AS T2 ON T1.club_id = T2.club_id GROUP BY T1.club_id


Question: How many gold medals has the club with the most coaches won?

Context: CREATE TABLE match_result (club_id VARCHAR, gold VARCHAR); CREATE TABLE coach (club_id VARCHAR)

SELECT T1.club_id, T1.gold FROM match_result AS T1 JOIN coach AS T2 ON T1.club_id = T2.club_id GROUP BY T1.club_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many gymnasts are there?

Context: CREATE TABLE gymnast (Id VARCHAR)


Question: List the total points of gymnasts in descending order.

Context: CREATE TABLE gymnast (Total_Points VARCHAR)

SELECT Total_Points FROM gymnast ORDER BY Total_Points DESC


Question: List the total points of gymnasts in descending order of floor exercise points.

Context: CREATE TABLE gymnast (Total_Points VARCHAR, Floor_Exercise_Points VARCHAR)

SELECT Total_Points FROM gymnast ORDER BY Floor_Exercise_Points DESC


Question: What is the average horizontal bar points for all gymnasts?

Context: CREATE TABLE gymnast (Horizontal_Bar_Points INTEGER)

SELECT AVG(Horizontal_Bar_Points) FROM gymnast


Question: What are the names of people in ascending alphabetical order?

Context: CREATE TABLE People (Name VARCHAR)


Question: What are the names of gymnasts?

Context: CREATE TABLE gymnast (Gymnast_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID


Question: What are the names of gymnasts whose hometown is not "Santo Domingo"?

Context: CREATE TABLE gymnast (Gymnast_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR, Hometown VARCHAR)

SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T2.Hometown <> "Santo Domingo"


Question: What is the age of the tallest person?

Context: CREATE TABLE people (Age VARCHAR, Height VARCHAR)

SELECT Age FROM people ORDER BY Height DESC LIMIT 1


Question: List the names of the top 5 oldest people.

Context: CREATE TABLE People (Name VARCHAR, Age VARCHAR)

SELECT Name FROM People ORDER BY Age DESC LIMIT 5


Question: What is the total point count of the youngest gymnast?

Context: CREATE TABLE people (People_ID VARCHAR, Age VARCHAR); CREATE TABLE gymnast (Total_Points VARCHAR, Gymnast_ID VARCHAR)

SELECT T1.Total_Points FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Age LIMIT 1


Question: What is the average age of all gymnasts?

Context: CREATE TABLE people (Age INTEGER, People_ID VARCHAR); CREATE TABLE gymnast (Gymnast_ID VARCHAR)

SELECT AVG(T2.Age) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID


Question: What are the distinct hometowns of gymnasts with total points more than 57.5?

Context: CREATE TABLE gymnast (Gymnast_ID VARCHAR, Total_Points INTEGER); CREATE TABLE people (Hometown VARCHAR, People_ID VARCHAR)

SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID WHERE T1.Total_Points > 57.5


Question: What are the hometowns of gymnasts and the corresponding number of gymnasts?

Context: CREATE TABLE gymnast (Gymnast_ID VARCHAR); CREATE TABLE people (Hometown VARCHAR, People_ID VARCHAR)

SELECT T2.Hometown, COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown


Question: What is the most common hometown of gymnasts?

SELECT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the hometowns that are shared by at least two gymnasts?

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


Question: List the names of gymnasts in ascending order by their heights.

Context: CREATE TABLE gymnast (Gymnast_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR, Height VARCHAR)

SELECT T2.Name FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T2.Height


Question: List the distinct hometowns that are not associated with any gymnast.

Context: CREATE TABLE gymnast (Gymnast_ID VARCHAR); CREATE TABLE people (Hometown VARCHAR, People_ID VARCHAR); CREATE TABLE people (Hometown VARCHAR)

SELECT DISTINCT Hometown FROM people EXCEPT SELECT DISTINCT T2.Hometown FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID


Question: Show the hometowns shared by people older than 23 and younger than 20.

Context: CREATE TABLE people (Hometown VARCHAR, Age INTEGER)

SELECT Hometown FROM people WHERE Age > 23 INTERSECT SELECT Hometown FROM people WHERE Age < 20


Question: How many distinct hometowns did these people have?

Context: CREATE TABLE people (Hometown VARCHAR)

SELECT COUNT(DISTINCT Hometown) FROM people


Question: Show the ages of gymnasts in descending order of total points.

Context: CREATE TABLE people (Age VARCHAR, People_ID VARCHAR); CREATE TABLE gymnast (Gymnast_ID VARCHAR, Total_Points VARCHAR)

SELECT T2.Age FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID ORDER BY T1.Total_Points DESC


Question: Find the total savings balance of all accounts except the account with name ‘Brown’.

Context: CREATE TABLE accounts (custid VARCHAR, name VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR)

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


Question: How many accounts are there in total?

Context: CREATE TABLE accounts (Id VARCHAR)


Question: What is the total checking balance in all accounts?

Context: CREATE TABLE checking (balance INTEGER)


Question: Find the average checking balance.

Context: CREATE TABLE checking (balance INTEGER)


Question: How many accounts have a savings balance above the average savings balance?

Context: CREATE TABLE savings (balance INTEGER)

SELECT COUNT(*) FROM savings WHERE balance > (SELECT AVG(balance) FROM savings)


Question: Find the name and id of accounts whose checking balance is below the maximum checking balance.

Context: CREATE TABLE accounts (custid VARCHAR, name VARCHAR); CREATE TABLE checking (balance INTEGER); CREATE TABLE checking (custid VARCHAR, balance INTEGER)

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)


Question: What is the checking balance of the account whose owner’s name contains the substring ‘ee’?

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (custid VARCHAR, name VARCHAR)

SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name LIKE '%ee%'


Question: Find the checking balance and saving balance in the Brown’s account.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (custid VARCHAR, name VARCHAR); CREATE TABLE savings (balance VARCHAR, custid VARCHAR)

SELECT T2.balance, T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T1.name = 'Brown'


Question: Find the names of accounts whose checking balance is above the average checking balance, but savings balance is below the average savings balance.

Context: CREATE TABLE checking (custid VARCHAR, balance INTEGER); CREATE TABLE savings (custid VARCHAR, balance INTEGER); CREATE TABLE savings (balance INTEGER); CREATE TABLE checking (balance INTEGER); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT AVG(balance) FROM checking) INTERSECT SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT AVG(balance) FROM savings)


Question: Find the checking balance of the accounts whose savings balance is higher than the average savings balance.

Context: CREATE TABLE accounts (custid VARCHAR, name VARCHAR); CREATE TABLE checking (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER)

SELECT T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T1.name IN (SELECT T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid WHERE T2.balance > (SELECT AVG(balance) FROM savings))


Question: List all customers’ names in the alphabetical order.

Context: CREATE TABLE accounts (name VARCHAR)


Question: Find the name of account that has the lowest total checking and saving balance.

Context: CREATE TABLE checking (custid VARCHAR, balance VARCHAR); CREATE TABLE savings (custid VARCHAR, balance VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T1.name 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 + T3.balance LIMIT 1


Question: Find the names and total checking and savings balances of accounts whose savings balance is higher than the average savings balance.

Context: CREATE TABLE checking (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T1.name, T2.balance + T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance > (SELECT AVG(balance) FROM savings)


Question: Find the name and checking balance of the account with the lowest savings balance.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE savings (custid VARCHAR, balance VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T1.name, T2.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 T3.balance LIMIT 1


Question: Find the number of checking accounts for each account name.

Context: CREATE TABLE checking (custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT COUNT(*), T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid GROUP BY T1.name


Question: Find the total saving balance for each account name.

Context: CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT SUM(T2.balance), T1.name FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid GROUP BY T1.name


Question: Find the name of accounts whose checking balance is below the average checking balance.

Context: CREATE TABLE accounts (name VARCHAR, custid VARCHAR); CREATE TABLE checking (balance INTEGER); CREATE TABLE checking (custid VARCHAR, balance INTEGER)

SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid WHERE T2.balance < (SELECT AVG(balance) FROM checking)


Question: Find the saving balance of the account with the highest checking balance.

Context: CREATE TABLE savings (balance VARCHAR, custid VARCHAR); CREATE TABLE checking (custid VARCHAR, balance VARCHAR); CREATE TABLE accounts (custid VARCHAR)

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: Find the total checking and saving balance of all accounts sorted by the total balance in ascending order.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE savings (balance VARCHAR, custid VARCHAR)

SELECT T1.balance + T2.balance FROM checking AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T1.balance + T2.balance


Question: Find the name and checking balance of the account with the lowest saving balance.

SELECT T2.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid ORDER BY T3.balance LIMIT 1


Question: Find the name, checking balance and saving balance of all accounts in the bank.

Context: CREATE TABLE checking (balance VARCHAR, custid VARCHAR); CREATE TABLE savings (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T2.balance, T3.balance, T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid


Question: Find the name, checking balance and savings balance of all accounts in the bank sorted by their total checking and savings balance in descending order.

SELECT T2.balance, T3.balance, T1.name 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 + T3.balance DESC


Question: Find the name of accounts whose checking balance is higher than corresponding saving balance.

Context: CREATE TABLE savings (custid VARCHAR, balance INTEGER); CREATE TABLE accounts (name VARCHAR, custid VARCHAR); CREATE TABLE checking (custid VARCHAR, balance INTEGER)

SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T2.balance > T3.balance


Question: Find the name and total checking and savings balance of the accounts whose savings balance is lower than corresponding checking balance.

Context: CREATE TABLE checking (balance INTEGER, custid VARCHAR); CREATE TABLE savings (balance INTEGER, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T1.name, T3.balance + T2.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance < T2.balance


Question: Find the name and savings balance of the top 3 accounts with the highest saving balance sorted by savings balance in descending order.

Context: CREATE TABLE savings (balance VARCHAR, custid VARCHAR); CREATE TABLE accounts (name VARCHAR, custid VARCHAR)

SELECT T1.name, T2.balance FROM accounts AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T2.balance DESC LIMIT 3


Question: How many main stream browsers whose market share is at least 5 exist?

Context: CREATE TABLE browser (market_share VARCHAR)

SELECT COUNT(*) FROM browser WHERE market_share >= 5


Question: List the name of browsers in descending order by market share.

Context: CREATE TABLE browser (name VARCHAR, market_share VARCHAR)

SELECT name FROM browser ORDER BY market_share DESC


Question: List the ids, names and market shares of all browsers.

Context: CREATE TABLE browser (id VARCHAR, name VARCHAR, market_share VARCHAR)

SELECT id, name, market_share FROM browser


Question: What is the maximum, minimum and average market share of the listed browsers?

Context: CREATE TABLE browser (market_share INTEGER)

SELECT MAX(market_share), MIN(market_share), AVG(market_share) FROM browser


Question: What is the id and market share of the browser Safari?

Context: CREATE TABLE browser (id VARCHAR, market_share VARCHAR, name VARCHAR)

SELECT id, market_share FROM browser WHERE name = 'Safari'


Question: What are the name and os of web client accelerators that do not work with only a 'Broadband' type connection?

Context: CREATE TABLE web_client_accelerator (name VARCHAR, operating_system VARCHAR, CONNECTION VARCHAR)

SELECT name, operating_system FROM web_client_accelerator WHERE CONNECTION <> 'Broadband'


Question: What is the name of the browser that became compatible with the accelerator 'CProxy' after year 1998 ?

Context: CREATE TABLE accelerator_compatible_browser (browser_id VARCHAR, accelerator_id VARCHAR, compatible_since_year VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, name VARCHAR); CREATE TABLE browser (name VARCHAR, id VARCHAR)

SELECT T1.name FROM browser AS T1 JOIN accelerator_compatible_browser AS T2 ON T1.id = T2.browser_id JOIN web_client_accelerator AS T3 ON T2.accelerator_id = T3.id WHERE T3.name = 'CProxy' AND T2.compatible_since_year > 1998


Question: What are the ids and names of the web accelerators that are compatible with two or more browsers?

Context: CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, Name VARCHAR)

SELECT T1.id, T1.Name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 2


Question: What is the id and name of the browser that is compatible with the most web accelerators?

Context: CREATE TABLE browser (id VARCHAR, name VARCHAR); CREATE TABLE accelerator_compatible_browser (browser_id VARCHAR)

SELECT T1.id, T1.name FROM browser AS T1 JOIN accelerator_compatible_browser AS T2 ON T1.id = T2.browser_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1


Question: When did the web accelerator 'CACHEbox' and browser 'Internet Explorer' become compatible?

Context: CREATE TABLE accelerator_compatible_browser (compatible_since_year VARCHAR, browser_id VARCHAR, accelerator_id VARCHAR); CREATE TABLE browser (id VARCHAR, name VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, name VARCHAR)

SELECT T1.compatible_since_year FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN web_client_accelerator AS T3 ON T1.accelerator_id = T3.id WHERE T3.name = 'CACHEbox' AND T2.name = 'Internet Explorer'


Question: How many different kinds of clients are supported by the web clients accelerators?

Context: CREATE TABLE web_client_accelerator (client VARCHAR)

SELECT COUNT(DISTINCT client) FROM web_client_accelerator


Question: How many accelerators are not compatible with the browsers listed ?

Context: CREATE TABLE accelerator_compatible_browser (id VARCHAR, accelerator_id VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, accelerator_id VARCHAR)

SELECT COUNT(*) FROM web_client_accelerator WHERE NOT id IN (SELECT accelerator_id FROM accelerator_compatible_browser)


Question: What distinct accelerator names are compatible with the browswers that have market share higher than 15?

Context: CREATE TABLE web_client_accelerator (name VARCHAR, id VARCHAR); CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR, browser_id VARCHAR); CREATE TABLE browser (id VARCHAR, market_share INTEGER)

SELECT DISTINCT T1.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.market_share > 15


Question: List the names of the browser that are compatible with both 'CACHEbox' and 'Fasterfox'.

Context: CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR, browser_id VARCHAR); CREATE TABLE web_client_accelerator (id VARCHAR, name VARCHAR); CREATE TABLE browser (name VARCHAR, id VARCHAR)

SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'CACHEbox' INTERSECT SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'Fasterfox'


Question: Show the accelerator names and supporting operating systems that are not compatible with the browser named 'Opera'.

Context: CREATE TABLE browser (id VARCHAR, name VARCHAR); CREATE TABLE web_client_accelerator (name VARCHAR, operating_system VARCHAR); CREATE TABLE accelerator_compatible_browser (accelerator_id VARCHAR, browser_id VARCHAR); CREATE TABLE web_client_accelerator (name VARCHAR, operating_system VARCHAR, id VARCHAR)

SELECT name, operating_system FROM web_client_accelerator EXCEPT SELECT T1.name, T1.operating_system FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T3.name = 'Opera'


Question: Which accelerator name contains substring "Opera"?

Context: CREATE TABLE web_client_accelerator (name VARCHAR)

SELECT name FROM web_client_accelerator WHERE name LIKE "%Opera%"


Question: Find the number of web accelerators used for each Operating system.

Context: CREATE TABLE web_client_accelerator (Operating_system VARCHAR)

SELECT Operating_system, COUNT(*) FROM web_client_accelerator GROUP BY Operating_system


Question: give me names of all compatible browsers and accelerators in the descending order of compatible year

Context: CREATE TABLE accelerator_compatible_browser (browser_id VARCHAR, accelerator_id VARCHAR, compatible_since_year VARCHAR); CREATE TABLE web_client_accelerator (name VARCHAR, id VARCHAR); CREATE TABLE browser (name VARCHAR, id VARCHAR)

SELECT T2.name, T3.name FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN web_client_accelerator AS T3 ON T1.accelerator_id = T3.id ORDER BY T1.compatible_since_year DESC


Question: How many wrestlers are there?

Context: CREATE TABLE wrestler (Id VARCHAR)


Question: List the names of wrestlers in descending order of days held.

Context: CREATE TABLE wrestler (Name VARCHAR, Days_held VARCHAR)

SELECT Name FROM wrestler ORDER BY Days_held DESC


Question: What is the name of the wrestler with the fewest days held?

SELECT Name FROM wrestler ORDER BY Days_held LIMIT 1


Question: What are the distinct reigns of wrestlers whose location is not "Tokyo,Japan" ?

Context: CREATE TABLE wrestler (Reign VARCHAR, LOCATION VARCHAR)

SELECT DISTINCT Reign FROM wrestler WHERE LOCATION <> "Tokyo , Japan"


Question: What are the names and location of the wrestlers?

Context: CREATE TABLE wrestler (Name VARCHAR, LOCATION VARCHAR)


Question: What are the elimination moves of wrestlers whose team is "Team Orton"?

Context: CREATE TABLE Elimination (Elimination_Move VARCHAR, Team VARCHAR)

SELECT Elimination_Move FROM Elimination WHERE Team = "Team Orton"


Question: What are the names of wrestlers and the elimination moves?

Context: CREATE TABLE wrestler (Name VARCHAR, Wrestler_ID VARCHAR); CREATE TABLE elimination (Elimination_Move VARCHAR, Wrestler_ID VARCHAR)

SELECT T2.Name, T1.Elimination_Move FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID


Question: List the names of wrestlers and the teams in elimination in descending order of days held.

Context: CREATE TABLE elimination (Team VARCHAR, Wrestler_ID VARCHAR); CREATE TABLE wrestler (Name VARCHAR, Wrestler_ID VARCHAR, Days_held VARCHAR)

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


Question: List the time of elimination of the wrestlers with largest days held.

Context: CREATE TABLE wrestler (Wrestler_ID VARCHAR, Days_held VARCHAR); CREATE TABLE elimination (Time VARCHAR, Wrestler_ID VARCHAR)

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


Question: Show times of elimination of wrestlers with days held more than 50.

Context: CREATE TABLE wrestler (Wrestler_ID VARCHAR, Days_held INTEGER); CREATE TABLE elimination (Time VARCHAR, Wrestler_ID VARCHAR)

SELECT T1.Time FROM elimination AS T1 JOIN wrestler AS T2 ON T1.Wrestler_ID = T2.Wrestler_ID WHERE T2.Days_held > 50


Question: Show different teams in eliminations and the number of eliminations from each team.

Context: CREATE TABLE elimination (Team VARCHAR)

SELECT Team, COUNT(*) FROM elimination GROUP BY Team


Question: Show teams that have suffered more than three eliminations.

Context: CREATE TABLE elimination (Team VARCHAR)

SELECT Team FROM elimination GROUP BY Team HAVING COUNT(*) > 3


Question: Show the reign and days held of wrestlers.

Context: CREATE TABLE wrestler (Reign VARCHAR, Days_held VARCHAR)


Question: What are the names of wrestlers days held less than 100?

Context: CREATE TABLE wrestler (Name VARCHAR, Days_held INTEGER)

SELECT Name FROM wrestler WHERE Days_held < 100


Question: Please show the most common reigns of wrestlers.

Context: CREATE TABLE wrestler (Reign VARCHAR)

SELECT Reign FROM wrestler GROUP BY Reign ORDER BY COUNT(*) DESC LIMIT 1


Question: List the locations that are shared by more than two wrestlers.

Context: CREATE TABLE wrestler (LOCATION VARCHAR)

SELECT LOCATION FROM wrestler GROUP BY LOCATION HAVING COUNT(*) > 2


Question: List the names of wrestlers that have not been eliminated.

Context: CREATE TABLE elimination (Name VARCHAR, Wrestler_ID VARCHAR); CREATE TABLE wrestler (Name VARCHAR, Wrestler_ID VARCHAR)

SELECT Name FROM wrestler WHERE NOT Wrestler_ID IN (SELECT Wrestler_ID FROM elimination)


Question: Show the teams that have both wrestlers eliminated by "Orton" and wrestlers eliminated by "Benjamin".

Context: CREATE TABLE Elimination (Team VARCHAR, Eliminated_By VARCHAR)

SELECT Team FROM Elimination WHERE Eliminated_By = "Orton" INTERSECT SELECT Team FROM Elimination WHERE Eliminated_By = "Benjamin"


Question: What is the number of distinct teams that suffer elimination?

Context: CREATE TABLE elimination (team VARCHAR)

SELECT COUNT(DISTINCT team) FROM elimination


Question: Show the times of elimination by "Punk" or "Orton".

Context: CREATE TABLE elimination (TIME VARCHAR, Eliminated_By VARCHAR)

SELECT TIME FROM elimination WHERE Eliminated_By = "Punk" OR Eliminated_By = "Orton"


Question: How many schools are there?

Context: CREATE TABLE school (Id VARCHAR)


Question: Show all school names in alphabetical order.

Context: CREATE TABLE school (school_name VARCHAR)

SELECT school_name FROM school ORDER BY school_name


Question: List the name, location, mascot for all schools.

Context: CREATE TABLE school (school_name VARCHAR, LOCATION VARCHAR, mascot VARCHAR)

SELECT school_name, LOCATION, mascot FROM school


Question: What are the total and average enrollment of all schools?

Context: CREATE TABLE school (enrollment INTEGER)

SELECT SUM(enrollment), AVG(enrollment) FROM school


Question: What are the mascots for schools with enrollments above the average?

Context: CREATE TABLE school (mascot VARCHAR, enrollment INTEGER)

SELECT mascot FROM school WHERE enrollment > (SELECT AVG(enrollment) FROM school)


Question: List the name of the school with the smallest enrollment.

Context: CREATE TABLE school (school_name VARCHAR, enrollment VARCHAR)

SELECT school_name FROM school ORDER BY enrollment LIMIT 1


Question: Show the average, maximum, minimum enrollment of all schools.

SELECT AVG(enrollment), MAX(enrollment), MIN(enrollment) FROM school


Question: Show each county along with the number of schools and total enrollment in each county.

Context: CREATE TABLE school (county VARCHAR, enrollment INTEGER)

SELECT county, COUNT(*), SUM(enrollment) FROM school GROUP BY county


Question: How many donors have endowment for school named "Glenn"?

Context: CREATE TABLE school (school_id VARCHAR, school_name VARCHAR); CREATE TABLE endowment (donator_name VARCHAR, school_id VARCHAR)

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: List each donator name and the amount of endowment in descending order of the amount of endowment.

Context: CREATE TABLE endowment (donator_name VARCHAR, amount INTEGER)

SELECT donator_name, SUM(amount) FROM endowment GROUP BY donator_name ORDER BY SUM(amount) DESC


Question: List the names of the schools without any endowment.

Context: CREATE TABLE endowment (school_name VARCHAR, school_id VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)

SELECT school_name FROM school WHERE NOT school_id IN (SELECT school_id FROM endowment)


Question: List all the names of schools with an endowment amount smaller than or equal to 10.

Context: CREATE TABLE school (school_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)

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


Question: Show the names of donors who donated to both school "Glenn" and "Triton."

SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton'


Question: Show the names of all the donors except those whose donation amount less than 9.

SELECT donator_name FROM endowment EXCEPT SELECT donator_name FROM endowment WHERE amount < 9


Question: List the amount and donor name for the largest amount of donation.

Context: CREATE TABLE endowment (amount VARCHAR, donator_name VARCHAR)

SELECT amount, donator_name FROM endowment ORDER BY amount DESC LIMIT 1


Question: How many budgets are above 3000 in year 2001 or before?

Context: CREATE TABLE budget (budgeted VARCHAR, YEAR VARCHAR)

SELECT COUNT(*) FROM budget WHERE budgeted > 3000 AND YEAR <= 2001


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

Context: CREATE TABLE budget (budgeted VARCHAR, invested VARCHAR, school_id VARCHAR, year VARCHAR); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)

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: Show all donor names.

Context: CREATE TABLE endowment (donator_name VARCHAR)

SELECT DISTINCT donator_name FROM endowment


Question: How many budget record has a budget amount smaller than the invested amount?

Context: CREATE TABLE budget (budgeted INTEGER, invested VARCHAR)

SELECT COUNT(*) FROM budget WHERE budgeted < invested


Question: What is the total budget amount for school "Glenn" in all years?

Context: CREATE TABLE budget (budgeted INTEGER, school_id VARCHAR); CREATE TABLE school (school_id VARCHAR, school_name VARCHAR)

SELECT SUM(T1.budgeted) FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn'


Question: Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10.

Context: CREATE TABLE endowment (school_id VARCHAR, amount INTEGER); CREATE TABLE budget (school_id VARCHAR, budgeted INTEGER); CREATE TABLE school (school_name VARCHAR, school_id VARCHAR)

SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING SUM(T1.budgeted) > 100 OR SUM(T3.amount) > 10


Question: Find the names of schools that have more than one donator with donation amount above 8.5.

Context: CREATE TABLE school (School_name VARCHAR, school_id VARCHAR); CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)

SELECT T2.School_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T1.amount > 8.5 GROUP BY T1.school_id HAVING COUNT(*) > 1


Question: Find the number of schools that have more than one donator whose donation amount is less than 8.5.

Context: CREATE TABLE endowment (school_id VARCHAR, amount INTEGER)

SELECT COUNT(*) FROM (SELECT * FROM endowment WHERE amount > 8.5 GROUP BY school_id HAVING COUNT(*) > 1)