Question:
Show the apartment type codes and the corresponding number of apartments sorted by the number of apartments in ascending order.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, COUNT(*) FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) ASC NULLS FIRST


Question:
Return each apartment type code with the number of apartments having that apartment type, in ascending order of the number of apartments.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, COUNT(*) FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) ASC NULLS FIRST


Question:
Show the top 3 apartment type codes sorted by the average number of rooms in descending order.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY AVG(room_count) DESC LIMIT 3


Question:
What are the top three apartment types in terms of the average room count? Give me the
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY AVG(room_count) DESC LIMIT 3


Question:
Show the apartment type code that has the largest number of total rooms, together with the number of bathrooms and number of bedrooms.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, bathroom_count, bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY SUM(room_count) DESC LIMIT 1


Question:
Which apartment type has the largest number of total rooms? Return the apartment type code, its number of bathrooms and number of bedrooms.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, bathroom_count, bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY SUM(room_count) DESC LIMIT 1


Question:
Show the most common apartment type code.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which apartment type code appears the most often?
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the most common apartment type code among apartments with more than 1 bathroom.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code FROM Apartments WHERE bathroom_count > 1 GROUP BY apt_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Which apartment type code is the most common among apartments with more than one bathroom?
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code FROM Apartments WHERE bathroom_count > 1 GROUP BY apt_type_code ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show each apartment type code, and the maximum and minimum number of rooms for each type.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, MAX(room_count), MIN(room_count) FROM Apartments GROUP BY apt_type_code


Question:
Return each apartment type code along with the maximum and minimum number of rooms among each type.
Additional table information: table: apartment_rentals

Answer: SELECT apt_type_code, MAX(room_count), MIN(room_count) FROM Apartments GROUP BY apt_type_code


Question:
Show each gender code and the corresponding count of guests sorted by the count in descending order.
Additional table information: table: apartment_rentals

Answer: SELECT gender_code, COUNT(*) FROM Guests GROUP BY gender_code ORDER BY COUNT(*) DESC


Question:
Sort the gender codes in descending order of their corresponding number of guests. Return both the gender codes and counts.
Additional table information: table: apartment_rentals

Answer: SELECT gender_code, COUNT(*) FROM Guests GROUP BY gender_code ORDER BY COUNT(*) DESC


Question:
How many apartments do not have any facility?
Additional table information: table: apartment_rentals

Answer: SELECT COUNT(*) FROM Apartments WHERE NOT apt_id IN (SELECT apt_id FROM Apartment_Facilities)


Question:
Find the number of apartments that have no facility.
Additional table information: table: apartment_rentals

Answer: SELECT COUNT(*) FROM Apartments WHERE NOT apt_id IN (SELECT apt_id FROM Apartment_Facilities)


Question:
Show the apartment numbers of apartments with bookings that have status code both 'Provisional' and 'Confirmed'
Additional table information: table: apartment_rentals

Answer: SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Confirmed' INTERSECT SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Provisional'


Question:
Which apartments have bookings with both status codes 'Provisional' and 'Confirmed'? Give me the apartment numbers.
Additional table information: table: apartment_rentals

Answer: SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Confirmed' INTERSECT SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Provisional'


Question:
Show the apartment numbers of apartments with unit status availability of both 0 and 1.
Additional table information: table: apartment_rentals

Answer: SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id = T2.apt_id WHERE T2.available_yn = 0 INTERSECT SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id = T2.apt_id WHERE T2.available_yn = 1


Question:
Which apartments have unit status availability of both 0 and 1? Return their apartment numbers.
Additional table information: table: apartment_rentals

Answer: SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id = T2.apt_id WHERE T2.available_yn = 0 INTERSECT SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id = T2.apt_id WHERE T2.available_yn = 1


Question:
How many games are held after season 2007?
Additional table information: table: game_injury

Answer: SELECT COUNT(*) FROM game WHERE season > 2007


Question:
List the dates of games by the home team name in descending order.
Additional table information: table: game_injury

Answer: SELECT Date FROM game ORDER BY home_team DESC


Question:
List the season, home team, away team of all the games.
Additional table information: table: game_injury

Answer: SELECT season, home_team, away_team FROM game


Question:
What are the maximum, minimum and average home games each stadium held?
Additional table information: table: game_injury

Answer: SELECT MAX(home_games), MIN(home_games), AVG(home_games) FROM stadium


Question:
What is the average attendance of stadiums with capacity percentage higher than 100%?
Additional table information: table: game_injury

Answer: SELECT average_attendance FROM stadium WHERE capacity_percentage > 100


Question:
What are the player name, number of matches, and information source for players who do not suffer from injury of 'Knee problem'?
Additional table information: table: game_injury

Answer: SELECT player, number_of_matches, SOURCE FROM injury_accident WHERE injury <> 'Knee problem'


Question:
What is the season of the game which causes the player 'Walter Samuel' to get injured?
Additional table information: table: game_injury

Answer: SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id = T2.game_id WHERE T2.player = 'Walter Samuel'


Question:
What are the ids, scores, and dates of the games which caused at least two injury accidents?
Additional table information: table: game_injury

Answer: SELECT T1.id, T1.score, T1.date FROM game AS T1 JOIN injury_accident AS T2 ON T2.game_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 2


Question:
What are the id and name of the stadium where the most injury accidents happened?
Additional table information: table: game_injury

Answer: SELECT T1.id, T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id = T2.stadium_id JOIN injury_accident AS T3 ON T2.id = T3.game_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1


Question:
Find the id and name of the stadium where the largest number of injury accidents occurred.
Additional table information: table: game_injury

Answer: SELECT T1.id, T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id = T2.stadium_id JOIN injury_accident AS T3 ON T2.id = T3.game_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1


Question:
In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'?
Additional table information: table: game_injury

Answer: SELECT T1.season, T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id WHERE T3.injury = 'Foot injury' OR T3.injury = 'Knee problem'


Question:
How many different kinds of information sources are there for injury accidents?
Additional table information: table: game_injury

Answer: SELECT COUNT(DISTINCT SOURCE) FROM injury_accident


Question:
How many games are free of injury accidents?
Additional table information: table: game_injury

Answer: SELECT COUNT(*) FROM game WHERE NOT id IN (SELECT game_id FROM injury_accident)


Question:
How many distinct kinds of injuries happened after season 2010?
Additional table information: table: game_injury

Answer: SELECT COUNT(DISTINCT T1.injury) FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id = T2.id WHERE T2.season > 2010


Question:
List the name of the stadium where both the player 'Walter Samuel' and the player 'Thiago Motta' got injured.
Additional table information: table: game_injury

Answer: SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id WHERE T3.player = 'Walter Samuel' INTERSECT SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id WHERE T3.player = 'Thiago Motta'


Question:
Show the name, average attendance, total attendance for stadiums where no accidents happened.
Additional table information: table: game_injury

Answer: SELECT name, average_attendance, total_attendance FROM stadium EXCEPT SELECT T2.name, T2.average_attendance, T2.total_attendance FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id


Question:
Which stadium name contains the substring 'Bank'?
Additional table information: table: game_injury

Answer: SELECT name FROM stadium WHERE name LIKE '%Bank%'


Question:
How many games has each stadium held?
Additional table information: table: game_injury

Answer: SELECT T1.id, COUNT(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id = T2.stadium_id GROUP BY T1.id


Question:
For each injury accident, find the date of the game and the name of the injured player in the game, and sort the results in descending order of game season.
Additional table information: table: game_injury

Answer: SELECT T1.date, T2.player FROM game AS T1 JOIN injury_accident AS T2 ON T1.id = T2.game_id ORDER BY T1.season DESC


Question:
List all country and league names.
Additional table information: table: soccer_1

Answer: SELECT T1.name, T2.name FROM Country AS T1 JOIN League AS T2 ON T1.id = T2.country_id


Question:
How many leagues are there in England?
Additional table information: table: soccer_1

Answer: SELECT COUNT(*) FROM Country AS T1 JOIN League AS T2 ON T1.id = T2.country_id WHERE T1.name = 'England'


Question:
What is the average weight of all players?
Additional table information: table: soccer_1

Answer: SELECT AVG(weight) FROM Player


Question:
What is the maximum and minimum height of all players?
Additional table information: table: soccer_1

Answer: SELECT MAX(weight), MIN(weight) FROM Player


Question:
List all player names who have an overall rating higher than the average.
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.overall_rating > (SELECT AVG(overall_rating) FROM Player_Attributes)


Question:
What are the names of players who have the best dribbling?
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.dribbling = (SELECT MAX(overall_rating) FROM Player_Attributes)


Question:
List the names of all players who have a crossing score higher than 90 and prefer their right foot.
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.crossing > 90 AND T2.preferred_foot = 'right'


Question:
List the names of all left-footed players who have overall rating between 85 and 90.
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.preferred_foot = 'left' AND T2.overall_rating >= 85 AND T2.overall_rating <= 90


Question:
What is the average rating for right-footed players and left-footed players?
Additional table information: table: soccer_1

Answer: SELECT preferred_foot, AVG(overall_rating) FROM Player_Attributes GROUP BY preferred_foot


Question:
Of all players with an overall rating greater than 80, how many are right-footed and left-footed?
Additional table information: table: soccer_1

Answer: SELECT preferred_foot, COUNT(*) FROM Player_Attributes WHERE overall_rating > 80 GROUP BY preferred_foot


Question:
List all of the player ids with a height of at least 180cm and an overall rating higher than 85.
Additional table information: table: soccer_1

Answer: SELECT player_api_id FROM Player WHERE height >= 180 INTERSECT SELECT player_api_id FROM Player_Attributes WHERE overall_rating > 85


Question:
List all of the ids for left-footed players with a height between 180cm and 190cm.
Additional table information: table: soccer_1

Answer: SELECT player_api_id FROM Player WHERE height >= 180 AND height <= 190 INTERSECT SELECT player_api_id FROM Player_Attributes WHERE preferred_foot = 'left'


Question:
Who are the top 3 players in terms of overall rating?
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id ORDER BY overall_rating DESC LIMIT 3


Question:
List the names and birthdays of the top five players in terms of potential.
Additional table information: table: soccer_1

Answer: SELECT DISTINCT T1.player_name, T1.birthday FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id ORDER BY potential DESC LIMIT 5


Question:
How many performances are there?
Additional table information: table: performance_attendance

Answer: SELECT COUNT(*) FROM performance


Question:
List the hosts of performances in ascending order of attendance.
Additional table information: table: performance_attendance

Answer: SELECT HOST FROM performance ORDER BY Attendance ASC NULLS FIRST


Question:
What are the dates and locations of performances?
Additional table information: table: performance_attendance

Answer: SELECT Date, LOCATION FROM performance


Question:
Show the attendances of the performances at location 'TD Garden' or 'Bell Centre'
Additional table information: table: performance_attendance

Answer: SELECT Attendance FROM performance WHERE LOCATION = 'TD Garden' OR LOCATION = 'Bell Centre'


Question:
What is the average number of attendees for performances?
Additional table information: table: performance_attendance

Answer: SELECT AVG(Attendance) FROM performance


Question:
What is the date of the performance with the highest number of attendees?
Additional table information: table: performance_attendance

Answer: SELECT Date FROM performance ORDER BY Attendance DESC LIMIT 1


Question:
Show different locations and the number of performances at each location.
Additional table information: table: performance_attendance

Answer: SELECT LOCATION, COUNT(*) FROM performance GROUP BY LOCATION


Question:
Show the most common location of performances.
Additional table information: table: performance_attendance

Answer: SELECT LOCATION FROM performance GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1


Question:
Show the locations that have at least two performances.
Additional table information: table: performance_attendance

Answer: SELECT LOCATION FROM performance GROUP BY LOCATION HAVING COUNT(*) >= 2


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

Answer: 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.
Additional table information: table: performance_attendance

Answer: 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.
Additional table information: table: performance_attendance

Answer: 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 ASC NULLS FIRST


Question:
Show the dates of performances with attending members whose roles are 'Violin'.
Additional table information: table: performance_attendance

Answer: 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.
Additional table information: table: performance_attendance

Answer: 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.
Additional table information: table: performance_attendance

Answer: 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.
Additional table information: table: college_2

Answer: SELECT DISTINCT building FROM classroom WHERE capacity > 50


Question:
What are the distinct buildings with capacities of greater than 50?
Additional table information: table: college_2

Answer: SELECT DISTINCT building FROM classroom WHERE capacity > 50


Question:
Count the number of rooms that are not in the Lamberton building.
Additional table information: table: college_2

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


Question:
How many classrooms are not in Lamberton?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
Give the name and building of the departments with greater than average budget.
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the room numbers and corresponding buildings for classrooms which can seat between 50 to 100 students?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What is the department name and corresponding building for the department with the greatest budget?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
Give the name of the student in the History department with the most credits.
Additional table information: table: college_2

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


Question:
How many rooms does the Lamberton building have?
Additional table information: table: college_2

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


Question:
Count the number of classrooms in Lamberton.
Additional table information: table: college_2

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


Question:
How many students have advisors?
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT s_id) FROM advisor


Question:
Count the number of students who have advisors.
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT s_id) FROM advisor


Question:
How many departments offer courses?
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT dept_name) FROM course


Question:
Count the number of departments which offer courses.
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT dept_name) FROM course


Question:
How many different courses offered by Physics department?
Additional table information: table: college_2

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


Question:
Count the number of courses in the Physics department.
Additional table information: table: college_2

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


Question:
Find the title of courses that have two prerequisites?
Additional table information: table: college_2

Answer: 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:
What are the titles for courses with two prerequisites?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

Answer: 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:
What is the title, credit value, and department name for courses with more than one prerequisite?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
Count the number of courses without prerequisites.
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
What are the titles of courses without prerequisites?
Additional table information: table: college_2

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


Question:
How many different instructors have taught some course?
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT id) FROM teaches


Question:
Count the number of distinct instructors who have taught a course.
Additional table information: table: college_2

Answer: SELECT COUNT(DISTINCT id) FROM teaches


Question:
Find the total budgets of the Marketing or Finance department.
Additional table information: table: college_2

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


Question:
What is the sum of budgets of the Marketing and Finance departments?
Additional table information: table: college_2

Answer: 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'.
Additional table information: table: college_2

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


Question:
What is the name of the department with an instructure who has a name like 'Soisalon'?
Additional table information: table: college_2

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


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

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


Question:
Count the number of rooms in Lamberton with capacity lower than 50.
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names and budgets of departments with budgets greater than the average?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

Answer: SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary NULLS FIRST LIMIT 1


Question:
Give the name of the lowest earning instructor in the Statistics department.
Additional table information: table: college_2

Answer: SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary NULLS FIRST LIMIT 1


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

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


Question:
What is the title of a course that is listed in both the Statistics and Psychology departments?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the titles of courses that are in the Statistics department but not the Psychology department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the ids of instructors who taught in the Fall of 2009 but not in the Spring of 2010?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of the students who took classes in 2009 or 2010?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
What are the names of the 3 departments with the most courses?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
What is the name of the department with the most credits?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: SELECT title FROM course ORDER BY title NULLS FIRST, credits NULLS FIRST


Question:
Given the titles of all courses, in order of titles and credits.
Additional table information: table: college_2

Answer: SELECT title FROM course ORDER BY title NULLS FIRST, credits NULLS FIRST


Question:
Which department has the lowest budget?
Additional table information: table: college_2

Answer: SELECT dept_name FROM department ORDER BY budget NULLS FIRST LIMIT 1


Question:
Give the name of the department with the lowest budget.
Additional table information: table: college_2

Answer: SELECT dept_name FROM department ORDER BY budget NULLS FIRST LIMIT 1


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

Answer: SELECT dept_name, building FROM department ORDER BY budget DESC


Question:
What are the names and buildings of the deparments, sorted by budget descending?
Additional table information: table: college_2

Answer: SELECT dept_name, building FROM department ORDER BY budget DESC


Question:
Who is the instructor with the highest salary?
Additional table information: table: college_2

Answer: SELECT name FROM instructor ORDER BY salary DESC LIMIT 1


Question:
Give the name of the highest paid instructor.
Additional table information: table: college_2

Answer: SELECT name FROM instructor ORDER BY salary DESC LIMIT 1


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

Answer: SELECT * FROM instructor ORDER BY salary NULLS FIRST


Question:
Give all information regarding instructors, in order of salary from least to greatest.
Additional table information: table: college_2

Answer: SELECT * FROM instructor ORDER BY salary NULLS FIRST


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

Answer: SELECT name, dept_name FROM student ORDER BY tot_cred NULLS FIRST


Question:
What are the names of students and their respective departments, ordered by number of credits from least to greatest?
Additional table information: table: college_2

Answer: SELECT name, dept_name FROM student ORDER BY tot_cred NULLS FIRST


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

Answer: 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 NULLS FIRST


Question:
Show all titles and their instructors' names for courses in 2008, in alphabetical order by title.
Additional table information: table: college_2

Answer: 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 NULLS FIRST


Question:
Find the name of instructors who are advising more than one student.
Additional table information: table: college_2

Answer: 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:
What are the names of instructors who advise more than one student?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

Answer: 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:
What are the names of students who have more than one advisor?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
How many rooms in each building have a capacity of over 50?
Additional table information: table: college_2

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


Question:
Find the maximum and average capacity among rooms in each building.
Additional table information: table: college_2

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


Question:
What are the greatest and average capacity for rooms in each building?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the titles of courses that are offered in more than one department?
Additional table information: table: college_2

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


Question:
Find the total credits of courses provided by different department.
Additional table information: table: college_2

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


Question:
How many total credits are offered by each department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What is the lowest salary in departments with average salary greater than the overall average.
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
How many courses are provided in each semester and year?
Additional table information: table: college_2

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


Question:
Find the year which offers the largest number of courses.
Additional table information: table: college_2

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


Question:
Which year had the greatest number of courses?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What is the year and semester with the most courses?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
What is the name of the deparment with the highest enrollment?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
How many students are in each department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: SELECT semester, YEAR FROM takes GROUP BY semester, YEAR ORDER BY COUNT(*) NULLS FIRST LIMIT 1


Question:
Which semeseter and year had the fewest students?
Additional table information: table: college_2

Answer: SELECT semester, YEAR FROM takes GROUP BY semester, YEAR ORDER BY COUNT(*) NULLS FIRST LIMIT 1


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

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


Question:
Give id of the instructor who advises students in the History department.
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

Answer: 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:
What are the names and salaries of instructors who advises students in the History department?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

Answer: SELECT course_id FROM course EXCEPT SELECT course_id FROM prereq


Question:
What are the ids of courses without prerequisites?
Additional table information: table: college_2

Answer: SELECT course_id FROM course EXCEPT SELECT course_id FROM prereq


Question:
Find the name of the courses that do not have any prerequisite?
Additional table information: table: college_2

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


Question:
What are the names of courses without prerequisites?
Additional table information: table: college_2

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


Question:
What is the title of the prerequisite class of International Finance course?
Additional table information: table: college_2

Answer: 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:
Give the title of the prerequisite to the course International Finance.
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What is the title of the course with Differential Geometry as a prerequisite?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of students who took a course in the Fall of 2003?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

Answer: 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:
Give the title of the course offered in Chandler during the Fall of 2010.
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What are the names of instructors who have taught C Programming courses?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What are the names and salaries of instructors who advise students in the Math department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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 NULLS FIRST


Question:
What are the names of all instructors who advise students in the math depart sorted by total credits of the student.
Additional table information: table: college_2

Answer: 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 NULLS FIRST


Question:
What is the course title of the prerequisite of course Mobile Computing?
Additional table information: table: college_2

Answer: 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:
What is the title of the course that is a prerequisite for Mobile Computing?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What is the name of the instructor who advises the student with the greatest number of total credits?
Additional table information: table: college_2

Answer: 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?
Additional table information: table: college_2

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


Question:
What are the names of instructors who didn't teach?
Additional table information: table: college_2

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


Question:
Find the id of instructors who didn't teach any courses?
Additional table information: table: college_2

Answer: SELECT id FROM instructor EXCEPT SELECT id FROM teaches


Question:
What are the ids of instructors who didnt' teach?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of instructors who didn't teach courses in the Spring?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
Which department has the highest average instructor salary?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
How many instructors are in the department with the highest budget, and what is their average salary?
Additional table information: table: college_2

Answer: 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)?
Additional table information: table: college_2

Answer: 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:
Give the title and credits for the course that is taught in the classroom with the greatest capacity.
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What are the names of students who haven't taken any Biology courses?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
How many students and instructors are in each department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What are the names of students who have taken the prerequisite for the course International Finance?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names and salaries for instructors who earn less than the average salary of instructors in the Physics department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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:
What are the names of students who have taken Statistics courses?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

Answer: 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 NULLS FIRST


Question:
What are the building, room number, semester and year of courses in the Psychology department, sorted using course title?
Additional table information: table: college_2

Answer: 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 NULLS FIRST


Question:
Find the names of all instructors in computer science department
Additional table information: table: college_2

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


Question:
What are the names of all instructors in the Comp. Sci. department?
Additional table information: table: college_2

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


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

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


Question:
What are the names of the instructors in the Comp. Sci. department who earn more than 80000?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of all instructors who have taught a course, as well as the corresponding course id?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of Art instructors who have taught a course, and the corresponding course id?
Additional table information: table: college_2

Answer: 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”.
Additional table information: table: college_2

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


Question:
What are the names of all instructors with names that include 'dar'?
Additional table information: table: college_2

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


Question:
List in alphabetic order the names of all distinct instructors.
Additional table information: table: college_2

Answer: SELECT DISTINCT name FROM instructor ORDER BY name NULLS FIRST


Question:
List the distinct names of the instructors, ordered by name.
Additional table information: table: college_2

Answer: SELECT DISTINCT name FROM instructor ORDER BY name NULLS FIRST


Question:
Find courses that ran in Fall 2009 or in Spring 2010.
Additional table information: table: college_2

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


Question:
What are the ids for courses in the Fall of 2009 or the Spring of 2010?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the ids for courses that were offered in both Fall of 2009 and Spring of 2010?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the ids of courses offered in Fall of 2009 but not in Spring of 2010?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the distinct salaries of all instructors who earned less than the maximum salary?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
How many instructors teach a course in the Spring of 2010?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names and average salaries for departments with average salary higher than 42000?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of instructors who earn more than at least one instructor from the Biology department?
Additional table information: table: college_2

Answer: 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.
Additional table information: table: college_2

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


Question:
What are the names of all instructors with a higher salary than any of the instructors in the Biology department?
Additional table information: table: college_2

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


Question:
How many debates are there?
Additional table information: table: debate

Answer: SELECT COUNT(*) FROM debate


Question:
List the venues of debates in ascending order of the number of audience.
Additional table information: table: debate

Answer: SELECT Venue FROM debate ORDER BY Num_of_Audience ASC NULLS FIRST


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

Answer: SELECT Date, Venue FROM debate


Question:
List the dates of debates with number of audience bigger than 150
Additional table information: table: debate

Answer: SELECT Date FROM debate WHERE Num_of_Audience > 150


Question:
Show the names of people aged either 35 or 36.
Additional table information: table: debate

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


Question:
What is the party of the youngest people?
Additional table information: table: debate

Answer: SELECT Party FROM people ORDER BY Age ASC NULLS FIRST LIMIT 1


Question:
Show different parties of people along with the number of people in each party.
Additional table information: table: debate

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


Question:
Show the party that has the most people.
Additional table information: table: debate

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


Question:
Show the distinct venues of debates
Additional table information: table: debate

Answer: SELECT DISTINCT Venue FROM debate


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

Answer: 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.
Additional table information: table: debate

Answer: 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 ASC NULLS FIRST


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

Answer: 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.
Additional table information: table: debate

Answer: 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.
Additional table information: table: debate

Answer: 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.
Additional table information: table: debate

Answer: 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.
Additional table information: table: insurance_and_eClaims

Answer: SELECT customer_details FROM customers ORDER BY customer_details NULLS FIRST


Question:
Sort the customer names in alphabetical order.
Additional table information: table: insurance_and_eClaims

Answer: SELECT customer_details FROM customers ORDER BY customer_details NULLS FIRST


Question:
Find all the policy type codes associated with the customer 'Dayana Robel'
Additional table information: table: insurance_and_eClaims

Answer: 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:
What are the type codes of the policies used by the customer 'Dayana Robel'?
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

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


Question:
Find the type code of the most frequently used policy.
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

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


Question:
Which types of policy are chosen by more than 2 customers? Give me the policy type codes.
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

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


Question:
What are the total amount and average amount paid in claim headers?
Additional table information: table: insurance_and_eClaims

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


Question:
Find the total amount claimed in the most recently created document.
Additional table information: table: insurance_and_eClaims

Answer: 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 NULLS FIRST LIMIT 1)


Question:
How much amount in total were claimed in the most recently created document?
Additional table information: table: insurance_and_eClaims

Answer: 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 NULLS FIRST LIMIT 1)


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

Answer: 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:
Which customer made the largest amount of claim in a single claim? Return the customer details.
Additional table information: table: insurance_and_eClaims

Answer: 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?
Additional table information: table: insurance_and_eClaims

Answer: 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:
Which customer made the smallest amount of claim in one claim? Return the customer details.
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

Answer: 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:
What are the names of customers who do not have any policies?
Additional table information: table: insurance_and_eClaims

Answer: 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?
Additional table information: table: insurance_and_eClaims

Answer: SELECT COUNT(*) FROM claims_processing_stages


Question:
Find the number of distinct stages in claim processing.
Additional table information: table: insurance_and_eClaims

Answer: SELECT COUNT(*) FROM claims_processing_stages


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

Answer: 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:
Which claim processing stage has the most claims? Show the claim status name.
Additional table information: table: insurance_and_eClaims

Answer: 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'.
Additional table information: table: insurance_and_eClaims

Answer: SELECT customer_details FROM customers WHERE customer_details LIKE '%Diana%'


Question:
Which customers have the substring 'Diana' in their names? Return the customer details.
Additional table information: table: insurance_and_eClaims

Answer: SELECT customer_details FROM customers WHERE customer_details LIKE '%Diana%'


Question:
Find the names of the customers who have an deputy policy.
Additional table information: table: insurance_and_eClaims

Answer: 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:
Which customers have an insurance policy with the type code 'Deputy'? Give me the customer details.
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

Answer: 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:
Which customers have an insurance policy with the type code 'Deputy' or 'Uniform'? Return the customer details.
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

Answer: SELECT customer_details FROM customers UNION SELECT staff_details FROM staff


Question:
What are the names of the customers and staff members?
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

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


Question:
For each policy type, return its type code and its count in the record.
Additional table information: table: insurance_and_eClaims

Answer: 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.
Additional table information: table: insurance_and_eClaims

Answer: 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:
Which customer have the most policies? Give me the customer details.
Additional table information: table: insurance_and_eClaims

Answer: 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'?
Additional table information: table: insurance_and_eClaims

Answer: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'Open'


Question:
Find the description of the claim status 'Open'.
Additional table information: table: insurance_and_eClaims

Answer: SELECT claim_status_description FROM claims_processing_stages WHERE claim_status_name = 'Open'


Question:
How many distinct claim outcome codes are there?
Additional table information: table: insurance_and_eClaims

Answer: SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing


Question:
Count the number of distinct claim outcome codes.
Additional table information: table: insurance_and_eClaims

Answer: SELECT COUNT(DISTINCT claim_outcome_code) FROM claims_processing


Question:
Which customer is associated with the latest policy?
Additional table information: table: insurance_and_eClaims

Answer: 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:
Find the customer who started a policy most recently.
Additional table information: table: insurance_and_eClaims

Answer: 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 number of accounts.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Accounts


Question:
How many accounts are there?
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Accounts


Question:
How many customers have opened an account?
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(DISTINCT customer_id) FROM Accounts


Question:
Count the number of customers who have an account.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(DISTINCT customer_id) FROM Accounts


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

Answer: SELECT account_id, date_account_opened, account_name, other_account_details FROM Accounts


Question:
What are the ids, date opened, name, and other details for all accounts?
Additional table information: table: customers_and_invoices

Answer: 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'.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the ids, names, dates of opening, and other details for accounts corresponding to the customer with the first name 'Meaghan'?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the names and other details for accounts corresponding to the customer named Meaghan Keeling?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the full names of customers with the account name 900?
Additional table information: table: customers_and_invoices

Answer: 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:
How many customers don't have an account?
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Customers WHERE NOT customer_id IN (SELECT customer_id FROM Accounts)


Question:
Count the number of customers who do not have an account.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Customers WHERE NOT customer_id IN (SELECT customer_id FROM Accounts)


Question:
Show the unique first names, last names, and phone numbers for all customers with any account.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the distinct first names, last names, and phone numbers for customers with accounts?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: SELECT customer_id FROM Customers EXCEPT SELECT customer_id FROM Accounts


Question:
What are the customer ids for customers who do not have an account?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
Count the number of accounts corresponding to each customer id.
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
Return the id and full name of the customer with the most accounts.
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the the full names and ids for all customers, and how many accounts does each have?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the first names and ids for customers who have two or more accounts?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Customers


Question:
Count the number of customers.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Customers


Question:
Show the number of customers for each gender.
Additional table information: table: customers_and_invoices

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


Question:
How many customers are there of each gender?
Additional table information: table: customers_and_invoices

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


Question:
How many transactions do we have?
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Financial_transactions


Question:
Count the number of transactions.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Financial_transactions


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

Answer: SELECT COUNT(*), account_id FROM Financial_transactions


Question:
Count the number of financial transactions that correspond to each account id.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*), account_id FROM Financial_transactions


Question:
How many transaction does account with name 337 have?
Additional table information: table: customers_and_invoices

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


Question:
Count the number of financial transactions that the account with the name 337 has.
Additional table information: table: customers_and_invoices

Answer: 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?
Additional table information: table: customers_and_invoices

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


Question:
Return the average, minimum, maximum, and total transaction amounts.
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
What are the ids for transactions that have an amount greater than the average amount of a transaction?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
What are total transaction amounts for each transaction type?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
Return the names and ids of each account, as well as the number of transactions.
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
What is the id of the account with the most transactions?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the ids and names of accounts with 4 or more transactions?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: SELECT DISTINCT product_size FROM Products


Question:
What are the different product sizes?
Additional table information: table: customers_and_invoices

Answer: SELECT DISTINCT product_size FROM Products


Question:
Show all product colors.
Additional table information: table: customers_and_invoices

Answer: SELECT DISTINCT product_color FROM Products


Question:
What are the different product colors?
Additional table information: table: customers_and_invoices

Answer: SELECT DISTINCT product_color FROM Products


Question:
Show the invoice number and the number of transactions for each invoice.
Additional table information: table: customers_and_invoices

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


Question:
How many transactions correspond to each invoice number?
Additional table information: table: customers_and_invoices

Answer: 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?
Additional table information: table: customers_and_invoices

Answer: 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:
What is the invoice number and invoice date corresponding to the invoice with the greatest number of transactions?
Additional table information: table: customers_and_invoices

Answer: 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?
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Invoices


Question:
Count the number of invoices.
Additional table information: table: customers_and_invoices

Answer: SELECT COUNT(*) FROM Invoices


Question:
Show invoice dates and order id and details for all invoices.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the invoice dates, order ids, and order details for all invoices?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
How many invoices correspond to each order id?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
Return the order ids and details for orderes with two or more invoices.
Additional table information: table: customers_and_invoices

Answer: 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?
Additional table information: table: customers_and_invoices

Answer: 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:
Return the last name, id and phone number of the customer who has made the greatest number of orders.
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the names of products that have never been ordered?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are the different product names, and what is the sum of quantity ordered for each product?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
How many order items correspond to each order id?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
How many distinct order ids correspond to each product?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

Answer: 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:
What are teh names of the different products, as well as the number of customers who have ordered each product.
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
How many different products correspond to each order id?
Additional table information: table: customers_and_invoices

Answer: 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.
Additional table information: table: customers_and_invoices

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


Question:
Give the order ids for all orders, as well as the total product quantity in each.
Additional table information: table: customers_and_invoices

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


Question:
How many products were not included in any order?
Additional table information: table: customers_and_invoices

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


Question:
Count the number of products that were never ordered.
Additional table information: table: customers_and_invoices

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


Question:
How many churches opened before 1850 are there?
Additional table information: table: wedding

Answer: SELECT COUNT(*) FROM Church WHERE Open_Date < 1850


Question:
Show the name, open date, and organizer for all churches.
Additional table information: table: wedding

Answer: SELECT name, open_date, organized_by FROM Church


Question:
List all church names in descending order of opening date.
Additional table information: table: wedding

Answer: SELECT name FROM church ORDER BY open_date DESC


Question:
Show the opening year in whcih at least two churches opened.
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

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


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

Answer: 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?
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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.
Additional table information: table: wedding

Answer: 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