Question: List the name of technicians whose team is not "NYY".

Context: CREATE TABLE technician (Name VARCHAR, Team VARCHAR)

Answer: [SQL] SELECT Name FROM technician WHERE Team <> "NYY" [/SQL]


Question: Show the name of technicians aged either 36 or 37

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

Answer: [SQL] SELECT Name FROM technician WHERE Age = 36 OR Age = 37 [/SQL]


Question: What is the starting year of the oldest technicians?

Context: CREATE TABLE technician (Starting_Year VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Starting_Year FROM technician ORDER BY Age DESC LIMIT 1 [/SQL]


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

Context: CREATE TABLE technician (Team VARCHAR)

Answer: [SQL] SELECT Team, COUNT(*) FROM technician GROUP BY Team [/SQL]


Question: Please show the team that has the most number of technicians.

Context: CREATE TABLE technician (Team VARCHAR)

Answer: [SQL] SELECT Team FROM technician GROUP BY Team ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the team that have at least two technicians.

Context: CREATE TABLE technician (Team VARCHAR)

Answer: [SQL] SELECT Team FROM technician GROUP BY Team HAVING COUNT(*) >= 2 [/SQL]


Question: Show names of technicians and series of machines they are assigned to repair.

Context: CREATE TABLE machine (Machine_series VARCHAR, machine_id VARCHAR); CREATE TABLE repair_assignment (machine_id VARCHAR, technician_ID VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

Answer: [SQL] SELECT T3.Name, T2.Machine_series FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID [/SQL]


Question: Show names of technicians in ascending order of quality rank of the machine they are assigned.

Context: CREATE TABLE repair_assignment (machine_id VARCHAR, technician_ID VARCHAR); CREATE TABLE machine (machine_id VARCHAR, quality_rank VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

Answer: [SQL] SELECT T3.Name FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID ORDER BY T2.quality_rank [/SQL]


Question: Show names of technicians who are assigned to repair machines with value point more than 70.

Context: CREATE TABLE machine (machine_id VARCHAR, value_points INTEGER); CREATE TABLE repair_assignment (machine_id VARCHAR, technician_ID VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

Answer: [SQL] SELECT T3.Name FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.machine_id = T2.machine_id JOIN technician AS T3 ON T1.technician_ID = T3.technician_ID WHERE T2.value_points > 70 [/SQL]


Question: Show names of technicians and the number of machines they are assigned to repair.

Context: CREATE TABLE repair_assignment (technician_ID VARCHAR); CREATE TABLE technician (Name VARCHAR, technician_ID VARCHAR)

Answer: [SQL] SELECT T2.Name, COUNT(*) FROM repair_assignment AS T1 JOIN technician AS T2 ON T1.technician_ID = T2.technician_ID GROUP BY T2.Name [/SQL]


Question: List the names of technicians who have not been assigned to repair machines.

Context: CREATE TABLE technician (Name VARCHAR, technician_id VARCHAR); CREATE TABLE repair_assignment (Name VARCHAR, technician_id VARCHAR)

Answer: [SQL] SELECT Name FROM technician WHERE NOT technician_id IN (SELECT technician_id FROM repair_assignment) [/SQL]


Question: Show the starting years shared by technicians from team "CLE" and "CWS".

Context: CREATE TABLE technician (Starting_Year VARCHAR, Team VARCHAR)

Answer: [SQL] SELECT Starting_Year FROM technician WHERE Team = "CLE" INTERSECT SELECT Starting_Year FROM technician WHERE Team = "CWS" [/SQL]


Question: How many entrepreneurs are there?

Context: CREATE TABLE entrepreneur (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM entrepreneur [/SQL]


Question: List the companies of entrepreneurs in descending order of money requested.

Context: CREATE TABLE entrepreneur (Company VARCHAR, Money_Requested VARCHAR)

Answer: [SQL] SELECT Company FROM entrepreneur ORDER BY Money_Requested DESC [/SQL]


Question: List the companies and the investors of entrepreneurs.

Context: CREATE TABLE entrepreneur (Company VARCHAR, Investor VARCHAR)

Answer: [SQL] SELECT Company, Investor FROM entrepreneur [/SQL]


Question: What is the average money requested by all entrepreneurs?

Context: CREATE TABLE entrepreneur (Money_Requested INTEGER)

Answer: [SQL] SELECT AVG(Money_Requested) FROM entrepreneur [/SQL]


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

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

Answer: [SQL] SELECT Name FROM People ORDER BY Weight [/SQL]


Question: What are the names of entrepreneurs?

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

Answer: [SQL] SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID [/SQL]


Question: What are the names of entrepreneurs whose investor is not "Rachel Elnaugh"?

Context: CREATE TABLE entrepreneur (People_ID VARCHAR, Investor VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor <> "Rachel Elnaugh" [/SQL]


Question: What is the weight of the shortest person?

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

Answer: [SQL] SELECT Weight FROM people ORDER BY Height LIMIT 1 [/SQL]


Question: What is the name of the entrepreneur with the greatest weight?

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR, Weight VARCHAR); CREATE TABLE entrepreneur (People_ID VARCHAR)

Answer: [SQL] SELECT T2.Name FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Weight DESC LIMIT 1 [/SQL]


Question: What is the total money requested by entrepreneurs with height more than 1.85?

Context: CREATE TABLE people (People_ID VARCHAR, Height INTEGER); CREATE TABLE entrepreneur (Money_Requested INTEGER, People_ID VARCHAR)

Answer: [SQL] SELECT SUM(T1.Money_Requested) FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Height > 1.85 [/SQL]


Question: What are the dates of birth of entrepreneurs with investor "Simon Woodroffe" or "Peter Jones"?

Context: CREATE TABLE entrepreneur (People_ID VARCHAR, Investor VARCHAR); CREATE TABLE people (Date_of_Birth VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T2.Date_of_Birth FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor = "Simon Woodroffe" OR T1.Investor = "Peter Jones" [/SQL]


Question: What are the weights of entrepreneurs in descending order of money requested?

Context: CREATE TABLE entrepreneur (People_ID VARCHAR, Money_Requested VARCHAR); CREATE TABLE people (Weight VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T2.Weight FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Money_Requested DESC [/SQL]


Question: What are the investors of entrepreneurs and the corresponding number of entrepreneurs invested by each investor?

Context: CREATE TABLE entrepreneur (Investor VARCHAR)

Answer: [SQL] SELECT Investor, COUNT(*) FROM entrepreneur GROUP BY Investor [/SQL]


Question: What is the investor that has invested in the most number of entrepreneurs?

Answer: [SQL] SELECT Investor FROM entrepreneur GROUP BY Investor ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the investors that have invested in at least two entrepreneurs?

Answer: [SQL] SELECT Investor FROM entrepreneur GROUP BY Investor HAVING COUNT(*) >= 2 [/SQL]


Question: List the names of entrepreneurs and their companies in descending order of money requested?

Context: CREATE TABLE entrepreneur (Company VARCHAR, People_ID VARCHAR, Money_Requested VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T2.Name, T1.Company FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Money_Requested [/SQL]


Question: List the names of people that are not entrepreneurs.

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

Answer: [SQL] SELECT Name FROM people WHERE NOT People_ID IN (SELECT People_ID FROM entrepreneur) [/SQL]


Question: Show the investors shared by entrepreneurs that requested more than 140000 and entrepreneurs that requested less than 120000.

Context: CREATE TABLE entrepreneur (Investor VARCHAR, Money_Requested INTEGER)

Answer: [SQL] SELECT Investor FROM entrepreneur WHERE Money_Requested > 140000 INTERSECT SELECT Investor FROM entrepreneur WHERE Money_Requested < 120000 [/SQL]


Question: How many distinct companies are there?

Context: CREATE TABLE entrepreneur (Company VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Company) FROM entrepreneur [/SQL]


Question: Show the company of the tallest entrepreneur.

Context: CREATE TABLE entrepreneur (Company VARCHAR, People_ID VARCHAR); CREATE TABLE people (People_ID VARCHAR, Height VARCHAR)

Answer: [SQL] SELECT T1.Company FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Height DESC LIMIT 1 [/SQL]


Question: How many perpetrators are there?

Context: CREATE TABLE perpetrator (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM perpetrator [/SQL]


Question: List the date of perpetrators in descending order of the number of people killed.

Context: CREATE TABLE perpetrator (Date VARCHAR, Killed VARCHAR)

Answer: [SQL] SELECT Date FROM perpetrator ORDER BY Killed DESC [/SQL]


Question: List the number of people injured by perpetrators in ascending order.

Context: CREATE TABLE perpetrator (Injured VARCHAR)

Answer: [SQL] SELECT Injured FROM perpetrator ORDER BY Injured [/SQL]


Question: What is the average number of people injured by all perpetrators?

Context: CREATE TABLE perpetrator (Injured INTEGER)

Answer: [SQL] SELECT AVG(Injured) FROM perpetrator [/SQL]


Question: What is the location of the perpetrator with the largest kills.

Context: CREATE TABLE perpetrator (LOCATION VARCHAR, Killed VARCHAR)

Answer: [SQL] SELECT LOCATION FROM perpetrator ORDER BY Killed DESC LIMIT 1 [/SQL]


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

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

Answer: [SQL] SELECT Name FROM People ORDER BY Height [/SQL]


Question: What are the names of perpetrators?

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

Answer: [SQL] SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID [/SQL]


Question: What are the names of perpetrators whose country is not "China"?

Context: CREATE TABLE perpetrator (People_ID VARCHAR, Country VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Country <> "China" [/SQL]


Question: What is the name of the perpetrator with the biggest weight.

Context: CREATE TABLE perpetrator (People_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR, Weight VARCHAR)

Answer: [SQL] SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Weight DESC LIMIT 1 [/SQL]


Question: What is the total kills of the perpetrators with height more than 1.84.

Context: CREATE TABLE people (People_ID VARCHAR, Height INTEGER); CREATE TABLE perpetrator (Killed INTEGER, People_ID VARCHAR)

Answer: [SQL] SELECT SUM(T2.Killed) FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Height > 1.84 [/SQL]


Question: What are the names of perpetrators in country "China" or "Japan"?

Answer: [SQL] SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID WHERE T2.Country = "China" OR T2.Country = "Japan" [/SQL]


Question: What are the heights of perpetrators in descending order of the number of people they injured?

Context: CREATE TABLE perpetrator (People_ID VARCHAR, Injured VARCHAR); CREATE TABLE people (Height VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T1.Height FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Injured DESC [/SQL]


Question: What are the countries of perpetrators? Show each country and the corresponding number of perpetrators there.

Context: CREATE TABLE perpetrator (Country VARCHAR)

Answer: [SQL] SELECT Country, COUNT(*) FROM perpetrator GROUP BY Country [/SQL]


Question: What is the country that has the most perpetrators?

Answer: [SQL] SELECT Country, COUNT(*) FROM perpetrator GROUP BY Country ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the countries that have at least two perpetrators?

Answer: [SQL] SELECT Country, COUNT(*) FROM perpetrator GROUP BY Country HAVING COUNT(*) >= 2 [/SQL]


Question: List the names of perpetrators in descending order of the year.

Context: CREATE TABLE perpetrator (People_ID VARCHAR, Year VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Year DESC [/SQL]


Question: List the names of people that are not perpetrators.

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

Answer: [SQL] SELECT Name FROM people WHERE NOT People_ID IN (SELECT People_ID FROM perpetrator) [/SQL]


Question: Show the countries that have both perpetrators with injures more than 50 and perpetrators with injures smaller than 20.

Context: CREATE TABLE perpetrator (Country VARCHAR, Injured INTEGER)

Answer: [SQL] SELECT Country FROM perpetrator WHERE Injured > 50 INTERSECT SELECT Country FROM perpetrator WHERE Injured < 20 [/SQL]


Question: How many distinct locations of perpetrators are there?

Context: CREATE TABLE perpetrator (LOCATION VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT LOCATION) FROM perpetrator [/SQL]


Question: Show the date of the tallest perpetrator.

Context: CREATE TABLE perpetrator (Date VARCHAR, People_ID VARCHAR); CREATE TABLE people (People_ID VARCHAR, Height VARCHAR)

Answer: [SQL] SELECT T2.Date FROM people AS T1 JOIN perpetrator AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Height DESC LIMIT 1 [/SQL]


Question: In which year did the most recent crime happen?

Context: CREATE TABLE perpetrator (YEAR INTEGER)

Answer: [SQL] SELECT MAX(YEAR) FROM perpetrator [/SQL]


Question: Report the name of all campuses in Los Angeles county.

Context: CREATE TABLE campuses (campus VARCHAR, county VARCHAR)

Answer: [SQL] SELECT campus FROM campuses WHERE county = "Los Angeles" [/SQL]


Question: What are the names of all campuses located at Chico?

Context: CREATE TABLE campuses (campus VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT campus FROM campuses WHERE LOCATION = "Chico" [/SQL]


Question: Find all the campuses opened in 1958.

Context: CREATE TABLE campuses (campus VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT campus FROM campuses WHERE YEAR = 1958 [/SQL]


Question: Find the name of the campuses opened before 1800.

Context: CREATE TABLE campuses (campus VARCHAR, YEAR INTEGER)

Answer: [SQL] SELECT campus FROM campuses WHERE YEAR < 1800 [/SQL]


Question: Which campus was opened between 1935 and 1939?

Answer: [SQL] SELECT campus FROM campuses WHERE YEAR >= 1935 AND YEAR <= 1939 [/SQL]


Question: Find the name of the campuses that is in Northridge, Los Angeles or in San Francisco, San Francisco.

Context: CREATE TABLE campuses (campus VARCHAR, LOCATION VARCHAR, county VARCHAR)

Answer: [SQL] SELECT campus FROM campuses WHERE LOCATION = "Northridge" AND county = "Los Angeles" UNION SELECT campus FROM campuses WHERE LOCATION = "San Francisco" AND county = "San Francisco" [/SQL]


Question: What is the campus fee of "San Jose State University" in year 1996?

Context: CREATE TABLE csu_fees (year VARCHAR); CREATE TABLE campuses (id VARCHAR)

Answer: [SQL] SELECT campusfee FROM campuses AS T1 JOIN csu_fees AS T2 ON T1.id = t2.campus WHERE t1.campus = "San Jose State University" AND T2.year = 1996 [/SQL]


Question: What is the campus fee of "San Francisco State University" in year 1996?

Answer: [SQL] SELECT campusfee FROM campuses AS T1 JOIN csu_fees AS T2 ON T1.id = t2.campus WHERE t1.campus = "San Francisco State University" AND T2.year = 1996 [/SQL]


Question: Find the count of universities whose campus fee is greater than the average campus fee.

Context: CREATE TABLE csu_fees (campusfee INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM csu_fees WHERE campusfee > (SELECT AVG(campusfee) FROM csu_fees) [/SQL]


Question: Which university is in Los Angeles county and opened after 1950?

Context: CREATE TABLE campuses (campus VARCHAR, county VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT campus FROM campuses WHERE county = "Los Angeles" AND YEAR > 1950 [/SQL]


Question: Which year has the most degrees conferred?

Context: CREATE TABLE degrees (YEAR VARCHAR, degrees INTEGER)

Answer: [SQL] SELECT YEAR FROM degrees GROUP BY YEAR ORDER BY SUM(degrees) DESC LIMIT 1 [/SQL]


Question: Which campus has the most degrees conferred in all times?

Context: CREATE TABLE degrees (campus VARCHAR, degrees INTEGER)

Answer: [SQL] SELECT campus FROM degrees GROUP BY campus ORDER BY SUM(degrees) DESC LIMIT 1 [/SQL]


Question: Which campus has the most faculties in year 2003?

Context: CREATE TABLE faculty (campus VARCHAR, year VARCHAR, faculty VARCHAR); CREATE TABLE campuses (campus VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.campus FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2003 ORDER BY T2.faculty DESC LIMIT 1 [/SQL]


Question: Find the average fee on a CSU campus in 1996

Context: CREATE TABLE csu_fees (campusfee INTEGER, YEAR VARCHAR)

Answer: [SQL] SELECT AVG(campusfee) FROM csu_fees WHERE YEAR = 1996 [/SQL]


Question: What is the average fee on a CSU campus in 2005?

Answer: [SQL] SELECT AVG(campusfee) FROM csu_fees WHERE YEAR = 2005 [/SQL]


Question: report the total number of degrees granted between 1998 and 2002.

Context: CREATE TABLE campuses (campus VARCHAR, id VARCHAR); CREATE TABLE degrees (degrees INTEGER, campus VARCHAR, year VARCHAR)

Answer: [SQL] SELECT T1.campus, SUM(T2.degrees) FROM campuses AS T1 JOIN degrees AS T2 ON T1.id = T2.campus WHERE T2.year >= 1998 AND T2.year <= 2002 GROUP BY T1.campus [/SQL]


Question: For each Orange county campus, report the number of degrees granted after 2000.

Context: CREATE TABLE campuses (campus VARCHAR, id VARCHAR, county VARCHAR); CREATE TABLE degrees (degrees INTEGER, campus VARCHAR, year VARCHAR)

Answer: [SQL] SELECT T1.campus, SUM(T2.degrees) FROM campuses AS T1 JOIN degrees AS T2 ON T1.id = T2.campus WHERE T1.county = "Orange" AND T2.year >= 2000 GROUP BY T1.campus [/SQL]


Question: Find the names of the campus which has more faculties in 2002 than every campus in Orange county.

Context: CREATE TABLE campuses (campus VARCHAR, id VARCHAR, county VARCHAR); CREATE TABLE faculty (campus VARCHAR, year VARCHAR)

Answer: [SQL] SELECT T1.campus FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2002 AND faculty > (SELECT MAX(faculty) FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2002 AND T1.county = "Orange") [/SQL]


Question: What campus had more than 400 total enrollment but more than 200 full time enrollment in year 1956?

Context: CREATE TABLE enrollments (campus VARCHAR, year VARCHAR); CREATE TABLE campuses (id VARCHAR)

Answer: [SQL] SELECT T1.campus FROM campuses AS t1 JOIN enrollments AS t2 ON t1.id = t2.campus WHERE t2.year = 1956 AND totalenrollment_ay > 400 AND FTE_AY > 200 [/SQL]


Question: How many campuses are there in Los Angeles county?

Context: CREATE TABLE campuses (county VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM campuses WHERE county = "Los Angeles" [/SQL]


Question: How many degrees were conferred in "San Jose State University" in 2000?

Context: CREATE TABLE degrees (Id VARCHAR); CREATE TABLE campuses (Id VARCHAR)

Answer: [SQL] SELECT degrees FROM campuses AS T1 JOIN degrees AS T2 ON t1.id = t2.campus WHERE t1.campus = "San Jose State University" AND t2.year = 2000 [/SQL]


Question: What are the degrees conferred in "San Francisco State University" in 2001.

Answer: [SQL] SELECT degrees FROM campuses AS T1 JOIN degrees AS T2 ON t1.id = t2.campus WHERE t1.campus = "San Francisco State University" AND t2.year = 2001 [/SQL]


Question: How many faculty is there in total in the year of 2002?

Context: CREATE TABLE faculty (faculty INTEGER, YEAR VARCHAR)

Answer: [SQL] SELECT SUM(faculty) FROM faculty WHERE YEAR = 2002 [/SQL]


Question: What is the number of faculty lines in campus "Long Beach State University" in 2002?

Context: CREATE TABLE campuses (id VARCHAR, campus VARCHAR); CREATE TABLE faculty (campus VARCHAR, year VARCHAR)

Answer: [SQL] SELECT faculty FROM faculty AS T1 JOIN campuses AS T2 ON T1.campus = T2.id WHERE T1.year = 2002 AND T2.campus = "Long Beach State University" [/SQL]


Question: How many faculty lines are there in "San Francisco State University" in year 2004?

Answer: [SQL] SELECT faculty FROM faculty AS T1 JOIN campuses AS T2 ON T1.campus = T2.id WHERE T1.year = 2004 AND T2.campus = "San Francisco State University" [/SQL]


Question: List the campus that have between 600 and 1000 faculty lines in year 2004.

Context: CREATE TABLE campuses (id VARCHAR); CREATE TABLE faculty (campus VARCHAR, faculty VARCHAR)

Answer: [SQL] SELECT T1.campus FROM campuses AS t1 JOIN faculty AS t2 ON t1.id = t2.campus WHERE t2.faculty >= 600 AND t2.faculty <= 1000 AND T1.year = 2004 [/SQL]


Question: How many faculty lines are there in the university that conferred the most number of degrees in year 2002?

Context: CREATE TABLE campuses (id VARCHAR); CREATE TABLE faculty (faculty VARCHAR); CREATE TABLE degrees (Id VARCHAR)

Answer: [SQL] SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2002 ORDER BY t3.degrees DESC LIMIT 1 [/SQL]


Question: How many faculty lines are there in the university that conferred the least number of degrees in year 2001?

Answer: [SQL] SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2001 ORDER BY t3.degrees LIMIT 1 [/SQL]


Question: How many undergraduates are there in "San Jose State University" in year 2004?

Context: CREATE TABLE discipline_enrollments (undergraduate INTEGER, campus VARCHAR, year VARCHAR); CREATE TABLE campuses (id VARCHAR, campus VARCHAR)

Answer: [SQL] SELECT SUM(t1.undergraduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Jose State University" [/SQL]


Question: What is the number of graduates in "San Francisco State University" in year 2004?

Context: CREATE TABLE discipline_enrollments (graduate INTEGER, campus VARCHAR, year VARCHAR); CREATE TABLE campuses (id VARCHAR, campus VARCHAR)

Answer: [SQL] SELECT SUM(t1.graduate) FROM discipline_enrollments AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t1.year = 2004 AND t2.campus = "San Francisco State University" [/SQL]


Question: What is the campus fee of "San Francisco State University" in year 2000?

Context: CREATE TABLE campuses (id VARCHAR, campus VARCHAR); CREATE TABLE csu_fees (campusfee VARCHAR, campus VARCHAR, year VARCHAR)

Answer: [SQL] SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Francisco State University" AND t1.year = 2000 [/SQL]


Question: Find the campus fee of "San Jose State University" in year 2000.

Answer: [SQL] SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Jose State University" AND t1.year = 2000 [/SQL]


Question: How many CSU campuses are there?

Context: CREATE TABLE campuses (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM campuses [/SQL]


Question: How many candidates are there?

Context: CREATE TABLE candidate (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM candidate [/SQL]


Question: Which poll resource provided the most number of candidate information?

Context: CREATE TABLE candidate (poll_source VARCHAR)

Answer: [SQL] SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: what are the top 3 highest support rates?

Context: CREATE TABLE candidate (support_rate VARCHAR)

Answer: [SQL] SELECT support_rate FROM candidate ORDER BY support_rate DESC LIMIT 3 [/SQL]


Question: Find the id of the candidate who got the lowest oppose rate.

Context: CREATE TABLE candidate (Candidate_ID VARCHAR, oppose_rate VARCHAR)

Answer: [SQL] SELECT Candidate_ID FROM candidate ORDER BY oppose_rate LIMIT 1 [/SQL]


Question: Please list support, consider, and oppose rates for each candidate in ascending order by unsure rate.

Context: CREATE TABLE candidate (Support_rate VARCHAR, Consider_rate VARCHAR, Oppose_rate VARCHAR, unsure_rate VARCHAR)

Answer: [SQL] SELECT Support_rate, Consider_rate, Oppose_rate FROM candidate ORDER BY unsure_rate [/SQL]


Question: which poll source does the highest oppose rate come from?

Context: CREATE TABLE candidate (poll_source VARCHAR, oppose_rate VARCHAR)

Answer: [SQL] SELECT poll_source FROM candidate ORDER BY oppose_rate DESC LIMIT 1 [/SQL]


Question: List all people names in the order of their date of birth from old to young.

Context: CREATE TABLE people (name VARCHAR, date_of_birth VARCHAR)

Answer: [SQL] SELECT name FROM people ORDER BY date_of_birth [/SQL]


Question: Find the average height and weight for all males (sex is M).

Context: CREATE TABLE people (height INTEGER, weight INTEGER, sex VARCHAR)

Answer: [SQL] SELECT AVG(height), AVG(weight) FROM people WHERE sex = 'M' [/SQL]


Question: find the names of people who are taller than 200 or lower than 190.

Context: CREATE TABLE people (name VARCHAR, height VARCHAR)

Answer: [SQL] SELECT name FROM people WHERE height > 200 OR height < 190 [/SQL]


Question: Find the average and minimum weight for each gender.

Context: CREATE TABLE people (sex VARCHAR, weight INTEGER)

Answer: [SQL] SELECT AVG(weight), MIN(weight), sex FROM people GROUP BY sex [/SQL]


Question: Find the name and gender of the candidate who got the highest support rate.

Context: CREATE TABLE candidate (people_id VARCHAR, support_rate VARCHAR); CREATE TABLE people (name VARCHAR, sex VARCHAR, people_id VARCHAR)

Answer: [SQL] SELECT t1.name, t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id ORDER BY t2.support_rate DESC LIMIT 1 [/SQL]


Question: Find the name of the candidates whose oppose percentage is the lowest for each sex.

Context: CREATE TABLE candidate (people_id VARCHAR); CREATE TABLE people (name VARCHAR, sex VARCHAR, people_id VARCHAR)

Answer: [SQL] SELECT t1.name, t1.sex, MIN(oppose_rate) FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex [/SQL]


Question: which gender got the highest average uncertain ratio.

Context: CREATE TABLE candidate (people_id VARCHAR, unsure_rate INTEGER); CREATE TABLE people (sex VARCHAR, people_id VARCHAR)

Answer: [SQL] SELECT t1.sex FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id GROUP BY t1.sex ORDER BY AVG(t2.unsure_rate) DESC LIMIT 1 [/SQL]


Question: what are the names of people who did not participate in the candidate election.

Context: CREATE TABLE candidate (name VARCHAR, people_id VARCHAR); CREATE TABLE people (name VARCHAR, people_id VARCHAR)

Answer: [SQL] SELECT name FROM people WHERE NOT people_id IN (SELECT people_id FROM candidate) [/SQL]


Question: Find the names of the candidates whose support percentage is lower than their oppose rate.

Context: CREATE TABLE candidate (people_id VARCHAR, support_rate INTEGER, oppose_rate VARCHAR); CREATE TABLE people (name VARCHAR, people_id VARCHAR)

Answer: [SQL] SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t2.support_rate < t2.oppose_rate [/SQL]


Question: how many people are there whose weight is higher than 85 for each gender?

Answer: [SQL] SELECT COUNT(*), sex FROM people WHERE weight > 85 GROUP BY sex [/SQL]


Question: find the highest support percentage, lowest consider rate and oppose rate of all candidates.

Context: CREATE TABLE candidate (support_rate INTEGER, consider_rate INTEGER, oppose_rate INTEGER)

Answer: [SQL] SELECT MAX(support_rate), MIN(consider_rate), MIN(oppose_rate) FROM candidate [/SQL]


Question: list all female (sex is F) candidate names in the alphabetical order.

Context: CREATE TABLE candidate (people_id VARCHAR); CREATE TABLE people (name VARCHAR, people_id VARCHAR, sex VARCHAR)

Answer: [SQL] SELECT t1.name FROM people AS t1 JOIN candidate AS t2 ON t1.people_id = t2.people_id WHERE t1.sex = 'F' ORDER BY t1.name [/SQL]


Question: find the name of people whose height is lower than the average.

Context: CREATE TABLE people (name VARCHAR, height INTEGER)

Answer: [SQL] SELECT name FROM people WHERE height < (SELECT AVG(height) FROM people) [/SQL]


Question: List all info about all people.

Context: CREATE TABLE people (Id VARCHAR)

Answer: [SQL] SELECT * FROM people [/SQL]


Question: Find the titles of all movies directed by steven spielberg.

Context: CREATE TABLE Movie (title VARCHAR, director VARCHAR)

Answer: [SQL] SELECT title FROM Movie WHERE director = 'Steven Spielberg' [/SQL]


Question: What is the name of the movie produced after 2000 and directed by James Cameron?

Context: CREATE TABLE Movie (title VARCHAR, director VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT title FROM Movie WHERE director = 'James Cameron' AND YEAR > 2000 [/SQL]


Question: How many movies were made before 2000?

Context: CREATE TABLE Movie (YEAR INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM Movie WHERE YEAR < 2000 [/SQL]


Question: Who is the director of movie Avatar?

Context: CREATE TABLE Movie (director VARCHAR, title VARCHAR)

Answer: [SQL] SELECT director FROM Movie WHERE title = 'Avatar' [/SQL]


Question: How many reviewers listed?

Context: CREATE TABLE Reviewer (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Reviewer [/SQL]


Question: What is the id of the reviewer whose name has substring “Mike”?

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR)

Answer: [SQL] SELECT rID FROM Reviewer WHERE name LIKE "%Mike%" [/SQL]


Question: What is the reviewer id of Daniel Lewis?

Answer: [SQL] SELECT rID FROM Reviewer WHERE name = "Daniel Lewis" [/SQL]


Question: What is the total number of ratings that has more than 3 stars?

Context: CREATE TABLE Rating (stars INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM Rating WHERE stars > 3 [/SQL]


Question: What is the lowest and highest rating star?

Context: CREATE TABLE Rating (stars INTEGER)

Answer: [SQL] SELECT MAX(stars), MIN(stars) FROM Rating [/SQL]


Question: Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order of year.

Context: CREATE TABLE Movie (mID VARCHAR, year VARCHAR); CREATE TABLE Rating (mID VARCHAR, stars VARCHAR)

Answer: [SQL] SELECT DISTINCT YEAR FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year [/SQL]


Question: What are the names of directors who directed movies with 5 star rating? Also return the title of these movies.

Context: CREATE TABLE Movie (director VARCHAR, title VARCHAR, mID VARCHAR); CREATE TABLE Rating (mID VARCHAR, stars VARCHAR)

Answer: [SQL] SELECT T1.director, T1.title FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars = 5 [/SQL]


Question: What is the average rating star for each reviewer?

Context: CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Rating (stars INTEGER, rID VARCHAR)

Answer: [SQL] SELECT T2.name, AVG(T1.stars) FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T2.name [/SQL]


Question: Find the titles of all movies that have no ratings.

Context: CREATE TABLE Rating (title VARCHAR, mID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT title FROM Movie WHERE NOT mID IN (SELECT mID FROM Rating) [/SQL]


Question: Find the names of all reviewers who have ratings with a NULL value for the date.

Context: CREATE TABLE Rating (rID VARCHAR); CREATE TABLE Reviewer (rID VARCHAR)

Answer: [SQL] SELECT DISTINCT name FROM Reviewer AS T1 JOIN Rating AS T2 ON T1.rID = T2.rID WHERE ratingDate = "null" [/SQL]


Question: What is the average rating stars and title for the oldest movie?

Context: CREATE TABLE Movie (title VARCHAR, mID VARCHAR, year VARCHAR); CREATE TABLE Rating (stars INTEGER, mID VARCHAR); CREATE TABLE Movie (YEAR INTEGER)

Answer: [SQL] SELECT AVG(T1.stars), T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT MIN(YEAR) FROM Movie) [/SQL]


Question: What is the name of the most recent movie?

Context: CREATE TABLE Movie (title VARCHAR, YEAR INTEGER)

Answer: [SQL] SELECT title FROM Movie WHERE YEAR = (SELECT MAX(YEAR) FROM Movie) [/SQL]


Question: What is the maximum stars and year for the most recent movie?

Context: CREATE TABLE Rating (stars INTEGER, mID VARCHAR); CREATE TABLE Movie (YEAR INTEGER); CREATE TABLE Movie (year VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT MAX(T1.stars), T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.year = (SELECT MAX(YEAR) FROM Movie) [/SQL]


Question: What is the names of movies whose created year is after all movies directed by Steven Spielberg?

Context: CREATE TABLE Movie (title VARCHAR, YEAR INTEGER, director VARCHAR)

Answer: [SQL] SELECT title FROM Movie WHERE YEAR > (SELECT MAX(YEAR) FROM Movie WHERE director = "Steven Spielberg") [/SQL]


Question: What are the titles and directors of the movies whose star is greater than the average stars of the movies directed by James Cameron?

Context: CREATE TABLE Rating (mID VARCHAR, stars INTEGER); CREATE TABLE Movie (title VARCHAR, director VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title, T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars > (SELECT AVG(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T2.director = "James Cameron") [/SQL]


Question: Return reviewer name, movie title, stars, and ratingDate. And sort the data first by reviewer name, then by movie title, and lastly by number of stars.

Context: CREATE TABLE Rating (stars VARCHAR, ratingDate VARCHAR, mID VARCHAR, rID VARCHAR); CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T3.name, T2.title, T1.stars, T1.ratingDate FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID ORDER BY T3.name, T2.title, T1.stars [/SQL]


Question: Find the names of all reviewers who have contributed three or more ratings.

Context: CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Rating (rID VARCHAR)

Answer: [SQL] SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID GROUP BY T1.rID HAVING COUNT(*) >= 3 [/SQL]


Question: Find the names of all reviewers who rated Gone with the Wind.

Context: CREATE TABLE Movie (mID VARCHAR, title VARCHAR); CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Rating (mID VARCHAR, rID VARCHAR)

Answer: [SQL] SELECT DISTINCT T3.name FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.title = 'Gone with the Wind' [/SQL]


Question: Find the names of all directors whose movies are rated by Sarah Martinez.

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR); CREATE TABLE Movie (director VARCHAR, mID VARCHAR); CREATE TABLE Rating (mID VARCHAR, rID VARCHAR)

Answer: [SQL] SELECT DISTINCT T2.director FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Sarah Martinez' [/SQL]


Question: For any rating where the name of reviewer is the same as the director of the movie, return the reviewer name, movie title, and number of stars.

Context: CREATE TABLE Rating (stars VARCHAR, mID VARCHAR, rID VARCHAR); CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR, director VARCHAR)

Answer: [SQL] SELECT DISTINCT T3.name, T2.title, T1.stars FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T2.director = T3.name [/SQL]


Question: Return all reviewer names and movie names together in a single list.

Context: CREATE TABLE Reviewer (name VARCHAR, title VARCHAR); CREATE TABLE Movie (name VARCHAR, title VARCHAR)

Answer: [SQL] SELECT name FROM Reviewer UNION SELECT title FROM Movie [/SQL]


Question: Find the titles of all movies not reviewed by Chris Jackson.

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR); CREATE TABLE Movie (title VARCHAR); CREATE TABLE Rating (mID VARCHAR, rID VARCHAR)

Answer: [SQL] SELECT DISTINCT title FROM Movie EXCEPT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Chris Jackson' [/SQL]


Question: For all directors who directed more than one movie, return the titles of all movies directed by them, along with the director name. Sort by director name, then movie title.

Context: CREATE TABLE Movie (title VARCHAR, director VARCHAR); CREATE TABLE Movie (director VARCHAR, title VARCHAR)

Answer: [SQL] SELECT T1.title, T1.director FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title <> T2.title ORDER BY T1.director, T1.title [/SQL]


Question: For directors who had more than one movie, return the titles and produced years of all movies directed by them.

Context: CREATE TABLE Movie (director VARCHAR, title VARCHAR); CREATE TABLE Movie (title VARCHAR, year VARCHAR, director VARCHAR)

Answer: [SQL] SELECT T1.title, T1.year FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title <> T2.title [/SQL]


Question: What are the names of the directors who made exactly one movie?

Context: CREATE TABLE Movie (director VARCHAR)

Answer: [SQL] SELECT director FROM Movie GROUP BY director HAVING COUNT(*) = 1 [/SQL]


Question: What are the names of the directors who made exactly one movie excluding director NULL?

Context: CREATE TABLE Movie (director VARCHAR)

Answer: [SQL] SELECT director FROM Movie WHERE director <> "null" GROUP BY director HAVING COUNT(*) = 1 [/SQL]


Question: How many movie reviews does each director get?

Context: CREATE TABLE Rating (mID VARCHAR); CREATE TABLE Movie (director VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT COUNT(*), T1.director FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID GROUP BY T1.director [/SQL]


Question: Find the movies with the highest average rating. Return the movie titles and average rating.

Context: CREATE TABLE Rating (stars INTEGER, mID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title, AVG(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY AVG(T1.stars) DESC LIMIT 1 [/SQL]


Question: What are the movie titles and average rating of the movies with the lowest average rating?

Answer: [SQL] SELECT T2.title, AVG(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY AVG(T1.stars) LIMIT 1 [/SQL]


Question: What are the names and years of the movies that has the top 3 highest rating star?

Context: CREATE TABLE Rating (mID VARCHAR, stars VARCHAR); CREATE TABLE Movie (title VARCHAR, year VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title, T2.year FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID ORDER BY T1.stars DESC LIMIT 3 [/SQL]


Question: For each director, return the director's name together with the title of the movie they directed that received the highest rating among all of their movies, and the value of that rating. Ignore movies whose director is NULL.

Context: CREATE TABLE Rating (stars INTEGER, mID VARCHAR); CREATE TABLE Movie (title VARCHAR, director VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title, T1.stars, T2.director, MAX(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE director <> "null" GROUP BY director [/SQL]


Question: Find the title and star rating of the movie that got the least rating star for each reviewer.

Context: CREATE TABLE Rating (rID VARCHAR, stars INTEGER, mID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title, T1.rID, T1.stars, MIN(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.rID [/SQL]


Question: Find the title and score of the movie with the lowest rating among all movies directed by each director.

Answer: [SQL] SELECT T2.title, T1.stars, T2.director, MIN(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T2.director [/SQL]


Question: What is the name of the movie that is rated by most of times?

Context: CREATE TABLE Rating (mID VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title, T1.mID FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID GROUP BY T1.mID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the titles of all movies that have rating star is between 3 and 5?

Context: CREATE TABLE Rating (mID VARCHAR, stars INTEGER); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5 [/SQL]


Question: Find the names of reviewers who had given higher than 3 star ratings.

Context: CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Rating (rID VARCHAR, stars INTEGER)

Answer: [SQL] SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars > 3 [/SQL]


Question: Find the average rating star for each movie that are not reviewed by Brittany Harris.

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR); CREATE TABLE Rating (mID VARCHAR, stars INTEGER); CREATE TABLE Rating (mID VARCHAR, rID VARCHAR)

Answer: [SQL] SELECT mID, AVG(stars) FROM Rating WHERE NOT mID IN (SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris") GROUP BY mID [/SQL]


Question: What are the ids of the movies that are not reviewed by Brittany Harris.

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR); CREATE TABLE Rating (mID VARCHAR); CREATE TABLE Rating (mID VARCHAR, rID VARCHAR)

Answer: [SQL] SELECT mID FROM Rating EXCEPT SELECT T1.mID FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T2.name = "Brittany Harris" [/SQL]


Question: Find the average rating star for each movie that received at least 2 ratings.

Context: CREATE TABLE Rating (mID VARCHAR, stars INTEGER)

Answer: [SQL] SELECT mID, AVG(stars) FROM Rating GROUP BY mID HAVING COUNT(*) >= 2 [/SQL]


Question: find the ids of reviewers who did not give 4 star.

Context: CREATE TABLE Rating (rID VARCHAR, stars VARCHAR)

Answer: [SQL] SELECT rID FROM Rating EXCEPT SELECT rID FROM Rating WHERE stars = 4 [/SQL]


Question: Find the ids of reviewers who didn't only give 4 star.

Answer: [SQL] SELECT rID FROM Rating WHERE stars <> 4 [/SQL]


Question: What are names of the movies that are either made after 2000 or reviewed by Brittany Harris?

Context: CREATE TABLE Reviewer (rID VARCHAR, name VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR, year VARCHAR); CREATE TABLE Rating (mID VARCHAR, rID VARCHAR)

Answer: [SQL] SELECT DISTINCT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID JOIN Reviewer AS T3 ON T1.rID = T3.rID WHERE T3.name = 'Brittany Harris' OR T2.year > 2000 [/SQL]


Question: What are names of the movies that are either made before 1980 or directed by James Cameron?

Context: CREATE TABLE Movie (title VARCHAR, director VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT title FROM Movie WHERE director = "James Cameron" OR YEAR < 1980 [/SQL]


Question: What are the names of reviewers who had rated 3 star and 4 star?

Context: CREATE TABLE Reviewer (name VARCHAR, rID VARCHAR); CREATE TABLE Rating (rID VARCHAR, stars VARCHAR)

Answer: [SQL] SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 3 INTERSECT SELECT T2.name FROM Rating AS T1 JOIN Reviewer AS T2 ON T1.rID = T2.rID WHERE T1.stars = 4 [/SQL]


Question: What are the names of movies that get 3 star and 4 star?

Context: CREATE TABLE Rating (mID VARCHAR, stars VARCHAR); CREATE TABLE Movie (title VARCHAR, mID VARCHAR)

Answer: [SQL] SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 3 INTERSECT SELECT T2.title FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars = 4 [/SQL]


Question: How many counties are there?

Context: CREATE TABLE county_public_safety (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM county_public_safety [/SQL]


Question: List the names of counties in descending order of population.

Context: CREATE TABLE county_public_safety (Name VARCHAR, Population VARCHAR)

Answer: [SQL] SELECT Name FROM county_public_safety ORDER BY Population DESC [/SQL]


Question: List the distinct police forces of counties whose location is not on east side.

Context: CREATE TABLE county_public_safety (Police_force VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION <> "East" [/SQL]


Question: What are the minimum and maximum crime rate of counties?

Context: CREATE TABLE county_public_safety (Crime_rate INTEGER)

Answer: [SQL] SELECT MIN(Crime_rate), MAX(Crime_rate) FROM county_public_safety [/SQL]


Question: Show the crime rates of counties in ascending order of number of police officers.

Context: CREATE TABLE county_public_safety (Crime_rate VARCHAR, Police_officers VARCHAR)

Answer: [SQL] SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers [/SQL]


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

Context: CREATE TABLE city (Name VARCHAR)

Answer: [SQL] SELECT Name FROM city ORDER BY Name [/SQL]


Question: What are the percentage of hispanics in cities with the black percentage higher than 10?

Context: CREATE TABLE city (Hispanic VARCHAR, Black INTEGER)

Answer: [SQL] SELECT Hispanic FROM city WHERE Black > 10 [/SQL]


Question: List the name of the county with the largest population.

Answer: [SQL] SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1 [/SQL]


Question: List the names of the city with the top 5 white percentages.

Context: CREATE TABLE city (Name VARCHAR, White VARCHAR)

Answer: [SQL] SELECT Name FROM city ORDER BY White DESC LIMIT 5 [/SQL]


Question: Show names of cities and names of counties they are in.

Context: CREATE TABLE city (Name VARCHAR, County_ID VARCHAR); CREATE TABLE county_public_safety (Name VARCHAR, County_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, T2.Name FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID [/SQL]


Question: Show white percentages of cities and the crime rates of counties they are in.

Context: CREATE TABLE city (White VARCHAR, County_ID VARCHAR); CREATE TABLE county_public_safety (Crime_rate VARCHAR, County_ID VARCHAR)

Answer: [SQL] SELECT T1.White, T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID [/SQL]


Question: Show the name of cities in the county that has the largest number of police officers.

Context: CREATE TABLE city (name VARCHAR, county_ID VARCHAR, Police_officers VARCHAR); CREATE TABLE county_public_safety (name VARCHAR, county_ID VARCHAR, Police_officers VARCHAR)

Answer: [SQL] SELECT name FROM city WHERE county_ID = (SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1) [/SQL]


Question: Show the number of cities in counties that have a population more than 20000.

Context: CREATE TABLE county_public_safety (county_ID VARCHAR, population INTEGER); CREATE TABLE city (county_ID VARCHAR, population INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM city WHERE county_ID IN (SELECT county_ID FROM county_public_safety WHERE population > 20000) [/SQL]


Question: Show the crime rate of counties with a city having white percentage more than 90.

Context: CREATE TABLE county_public_safety (Crime_rate VARCHAR, County_ID VARCHAR); CREATE TABLE city (County_ID VARCHAR, White INTEGER)

Answer: [SQL] SELECT T2.Crime_rate FROM city AS T1 JOIN county_public_safety AS T2 ON T1.County_ID = T2.County_ID WHERE T1.White > 90 [/SQL]


Question: Please show the police forces and the number of counties with each police force.

Context: CREATE TABLE county_public_safety (Police_force VARCHAR)

Answer: [SQL] SELECT Police_force, COUNT(*) FROM county_public_safety GROUP BY Police_force [/SQL]


Question: What is the location shared by most counties?

Context: CREATE TABLE county_public_safety (LOCATION VARCHAR)

Answer: [SQL] SELECT LOCATION FROM county_public_safety GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the names of counties that do not have any cities.

Answer: [SQL] SELECT Name FROM county_public_safety WHERE NOT County_ID IN (SELECT County_ID FROM city) [/SQL]


Question: Show the police force shared by counties with location on the east and west.

Answer: [SQL] SELECT Police_force FROM county_public_safety WHERE LOCATION = "East" INTERSECT SELECT Police_force FROM county_public_safety WHERE LOCATION = "West" [/SQL]


Question: Show the names of cities in counties that have a crime rate less than 100.

Context: CREATE TABLE county_public_safety (name VARCHAR, county_id VARCHAR, Crime_rate INTEGER); CREATE TABLE city (name VARCHAR, county_id VARCHAR, Crime_rate INTEGER)

Answer: [SQL] SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100) [/SQL]


Question: Show the case burden of counties in descending order of population.

Context: CREATE TABLE county_public_safety (Case_burden VARCHAR, Population VARCHAR)

Answer: [SQL] SELECT Case_burden FROM county_public_safety ORDER BY Population DESC [/SQL]


Question: Find the names of all modern rooms with a base price below $160 and two beds.

Context: CREATE TABLE Rooms (roomName VARCHAR, decor VARCHAR, basePrice VARCHAR, beds VARCHAR)

Answer: [SQL] SELECT roomName FROM Rooms WHERE basePrice < 160 AND beds = 2 AND decor = 'modern' [/SQL]


Question: Find all the rooms that have a price higher than 160 and can accommodate more than 2 people. Report room names and ids.

Context: CREATE TABLE Rooms (roomName VARCHAR, RoomId VARCHAR, basePrice VARCHAR, maxOccupancy VARCHAR)

Answer: [SQL] SELECT roomName, RoomId FROM Rooms WHERE basePrice > 160 AND maxOccupancy > 2 [/SQL]


Question: Find the most popular room in the hotel. The most popular room is the room that had seen the largest number of reservations.

Context: CREATE TABLE Reservations (Room VARCHAR); CREATE TABLE Rooms (roomName VARCHAR, RoomId VARCHAR)

Answer: [SQL] SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many kids stay in the rooms reserved by ROY SWEAZY?

Context: CREATE TABLE Reservations (kids VARCHAR, FirstName VARCHAR, LastName VARCHAR)

Answer: [SQL] SELECT kids FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY" [/SQL]


Question: How many times does ROY SWEAZY has reserved a room.

Context: CREATE TABLE Reservations (FirstName VARCHAR, LastName VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Reservations WHERE FirstName = "ROY" AND LastName = "SWEAZY" [/SQL]


Question: Which room has the highest rate? List the room's full name, rate, check in and check out date.

Context: CREATE TABLE Rooms (roomName VARCHAR, RoomId VARCHAR); CREATE TABLE Reservations (Rate VARCHAR, CheckIn VARCHAR, CheckOut VARCHAR, Room VARCHAR)

Answer: [SQL] SELECT T2.roomName, T1.Rate, T1.CheckIn, T1.CheckOut FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY T1.Rate DESC LIMIT 1 [/SQL]


Question: How many adults stay in the room CONRAD SELBIG checked in on Oct 23, 2010?

Context: CREATE TABLE Reservations (Adults VARCHAR, LastName VARCHAR, CheckIn VARCHAR, FirstName VARCHAR)

Answer: [SQL] SELECT Adults FROM Reservations WHERE CheckIn = "2010-10-23" AND FirstName = "CONRAD" AND LastName = "SELBIG" [/SQL]


Question: How many kids stay in the room DAMIEN TRACHSEL checked in on Sep 21, 2010?

Context: CREATE TABLE Reservations (Kids VARCHAR, LastName VARCHAR, CheckIn VARCHAR, FirstName VARCHAR)

Answer: [SQL] SELECT Kids FROM Reservations WHERE CheckIn = "2010-09-21" AND FirstName = "DAMIEN" AND LastName = "TRACHSEL" [/SQL]


Question: How many king beds are there?

Context: CREATE TABLE Rooms (beds INTEGER, bedtype VARCHAR)

Answer: [SQL] SELECT SUM(beds) FROM Rooms WHERE bedtype = 'King' [/SQL]


Question: List the names and decor of rooms that have a king bed. Sort the list by their price.

Context: CREATE TABLE Rooms (roomName VARCHAR, decor VARCHAR, bedtype VARCHAR, basePrice VARCHAR)

Answer: [SQL] SELECT roomName, decor FROM Rooms WHERE bedtype = 'King' ORDER BY basePrice [/SQL]


Question: Which room has cheapest base price? List the room's name and the base price.

Context: CREATE TABLE Rooms (roomName VARCHAR, basePrice VARCHAR)

Answer: [SQL] SELECT roomName, basePrice FROM Rooms ORDER BY basePrice LIMIT 1 [/SQL]


Question: What is the decor of room Recluse and defiance?

Context: CREATE TABLE Rooms (decor VARCHAR, roomName VARCHAR)

Answer: [SQL] SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance" [/SQL]


Question: What is the average base price of different bed type? List bed type and average base price.

Context: CREATE TABLE Rooms (bedType VARCHAR, basePrice INTEGER)

Answer: [SQL] SELECT bedType, AVG(basePrice) FROM Rooms GROUP BY bedType [/SQL]


Question: What is the total number of people who could stay in the modern rooms in this inn?

Context: CREATE TABLE Rooms (maxOccupancy INTEGER, decor VARCHAR)

Answer: [SQL] SELECT SUM(maxOccupancy) FROM Rooms WHERE decor = 'modern' [/SQL]


Question: What kind of decor has the least number of reservations?

Context: CREATE TABLE Reservations (Room VARCHAR); CREATE TABLE Rooms (decor VARCHAR, RoomId VARCHAR)

Answer: [SQL] SELECT T2.decor FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T2.decor ORDER BY COUNT(T2.decor) LIMIT 1 [/SQL]


Question: List how many times the number of people in the room reached the maximum occupancy of the room. The number of people include adults and kids.

Context: CREATE TABLE Rooms (RoomId VARCHAR, maxOccupancy VARCHAR); CREATE TABLE Reservations (Room VARCHAR, Adults VARCHAR, Kids VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T2.maxOccupancy = T1.Adults + T1.Kids [/SQL]


Question: Find the first and last names of people who payed more than the rooms' base prices.

Context: CREATE TABLE Reservations (firstname VARCHAR, lastname VARCHAR, Room VARCHAR, Rate VARCHAR); CREATE TABLE Rooms (RoomId VARCHAR, basePrice VARCHAR)

Answer: [SQL] SELECT T1.firstname, T1.lastname FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T1.Rate - T2.basePrice > 0 [/SQL]


Question: How many rooms are there?

Context: CREATE TABLE Rooms (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Rooms [/SQL]


Question: Find the number of rooms with a king bed.

Context: CREATE TABLE Rooms (bedType VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Rooms WHERE bedType = "King" [/SQL]


Question: Find the number of rooms for each bed type.

Context: CREATE TABLE Rooms (bedType VARCHAR)

Answer: [SQL] SELECT bedType, COUNT(*) FROM Rooms GROUP BY bedType [/SQL]


Question: Find the name of the room with the maximum occupancy.

Context: CREATE TABLE Rooms (roomName VARCHAR, maxOccupancy VARCHAR)

Answer: [SQL] SELECT roomName FROM Rooms ORDER BY maxOccupancy DESC LIMIT 1 [/SQL]


Question: Find the id and name of the most expensive base price room.

Context: CREATE TABLE Rooms (RoomId VARCHAR, roomName VARCHAR, basePrice VARCHAR)

Answer: [SQL] SELECT RoomId, roomName FROM Rooms ORDER BY basePrice DESC LIMIT 1 [/SQL]


Question: List the type of bed and name of all traditional rooms.

Context: CREATE TABLE Rooms (roomName VARCHAR, bedType VARCHAR, decor VARCHAR)

Answer: [SQL] SELECT roomName, bedType FROM Rooms WHERE decor = "traditional" [/SQL]


Question: Find the number of rooms with king bed for each decor type.

Context: CREATE TABLE Rooms (decor VARCHAR, bedType VARCHAR)

Answer: [SQL] SELECT decor, COUNT(*) FROM Rooms WHERE bedType = "King" GROUP BY decor [/SQL]


Question: Find the average and minimum price of the rooms in different decor.

Context: CREATE TABLE Rooms (decor VARCHAR, basePrice INTEGER)

Answer: [SQL] SELECT decor, AVG(basePrice), MIN(basePrice) FROM Rooms GROUP BY decor [/SQL]


Question: List the name of all rooms sorted by their prices.

Answer: [SQL] SELECT roomName FROM Rooms ORDER BY basePrice [/SQL]


Question: Find the number of rooms with price higher than 120 for different decor.

Answer: [SQL] SELECT decor, COUNT(*) FROM Rooms WHERE basePrice > 120 GROUP BY decor [/SQL]


Question: List the name of rooms with king or queen bed.

Context: CREATE TABLE Rooms (roomName VARCHAR, bedType VARCHAR)

Answer: [SQL] SELECT roomName FROM Rooms WHERE bedType = "King" OR bedType = "Queen" [/SQL]


Question: How many different types of beds are there?

Context: CREATE TABLE Rooms (bedType VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT bedType) FROM Rooms [/SQL]


Question: Find the name and id of the top 3 expensive rooms.

Answer: [SQL] SELECT RoomId, roomName FROM Rooms ORDER BY basePrice DESC LIMIT 3 [/SQL]


Question: Find the name of rooms whose price is higher than the average price.

Context: CREATE TABLE Rooms (roomName VARCHAR, basePrice INTEGER)

Answer: [SQL] SELECT roomName FROM Rooms WHERE basePrice > (SELECT AVG(basePrice) FROM Rooms) [/SQL]


Question: Find the number of rooms that do not have any reservation.

Context: CREATE TABLE rooms (roomid VARCHAR, room VARCHAR); CREATE TABLE reservations (roomid VARCHAR, room VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM rooms WHERE NOT roomid IN (SELECT DISTINCT room FROM reservations) [/SQL]


Question: Return the name and number of reservations made for each of the rooms.

Context: CREATE TABLE Reservations (Room VARCHAR); CREATE TABLE Rooms (roomName VARCHAR, RoomId VARCHAR)

Answer: [SQL] SELECT T2.roomName, COUNT(*), T1.Room FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room [/SQL]


Question: Find the names of rooms that have been reserved for more than 60 times.

Answer: [SQL] SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room HAVING COUNT(*) > 60 [/SQL]


Question: Find the name of rooms whose base price is between 120 and 150.

Context: CREATE TABLE rooms (roomname VARCHAR, baseprice INTEGER)

Answer: [SQL] SELECT roomname FROM rooms WHERE baseprice BETWEEN 120 AND 150 [/SQL]


Question: Find the name of rooms booked by some customers whose first name contains ROY.

Answer: [SQL] SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE firstname LIKE '%ROY%' [/SQL]


Question: what are the details of the cmi masters that have the cross reference code 'Tax'?

Context: CREATE TABLE CMI_Cross_References (master_customer_id VARCHAR, source_system_code VARCHAR); CREATE TABLE Customer_Master_Index (cmi_details VARCHAR, master_customer_id VARCHAR)

Answer: [SQL] SELECT T1.cmi_details FROM Customer_Master_Index AS T1 JOIN CMI_Cross_References AS T2 ON T1.master_customer_id = T2.master_customer_id WHERE T2.source_system_code = 'Tax' [/SQL]


Question: What is the cmi cross reference id that is related to at least one council tax entry? List the cross reference id and source system code.

Context: CREATE TABLE Council_Tax (cmi_cross_ref_id VARCHAR); CREATE TABLE CMI_Cross_References (cmi_cross_ref_id VARCHAR, source_system_code VARCHAR)

Answer: [SQL] SELECT T1.cmi_cross_ref_id, T1.source_system_code FROM CMI_Cross_References AS T1 JOIN Council_Tax AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id GROUP BY T1.cmi_cross_ref_id HAVING COUNT(*) >= 1 [/SQL]


Question: How many business rates are related to each cmi cross reference? List cross reference id, master customer id and the n

Context: CREATE TABLE CMI_Cross_References (cmi_cross_ref_id VARCHAR, master_customer_id VARCHAR); CREATE TABLE Business_Rates (cmi_cross_ref_id VARCHAR)

Answer: [SQL] SELECT T2.cmi_cross_ref_id, T2.master_customer_id, COUNT(*) FROM Business_Rates AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id GROUP BY T2.cmi_cross_ref_id [/SQL]


Question: What is the tax source system code related to the benefits and overpayments? List the code and the benifit id, order by benifit id.

Context: CREATE TABLE CMI_Cross_References (source_system_code VARCHAR, cmi_cross_ref_id VARCHAR); CREATE TABLE Benefits_Overpayments (council_tax_id VARCHAR, cmi_cross_ref_id VARCHAR)

Answer: [SQL] SELECT T1.source_system_code, T2.council_tax_id FROM CMI_Cross_References AS T1 JOIN Benefits_Overpayments AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id ORDER BY T2.council_tax_id [/SQL]


Question: Wat is the tax source system code and master customer id of the taxes related to each parking fine id?

Context: CREATE TABLE CMI_Cross_References (source_system_code VARCHAR, master_customer_id VARCHAR, cmi_cross_ref_id VARCHAR); CREATE TABLE Parking_Fines (council_tax_id VARCHAR, cmi_cross_ref_id VARCHAR)

Answer: [SQL] SELECT T1.source_system_code, T1.master_customer_id, T2.council_tax_id FROM CMI_Cross_References AS T1 JOIN Parking_Fines AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id [/SQL]


Question: What are the renting arrears tax ids related to the customer master index whose detail is not 'Schmidt, Kertzmann and Lubowitz'?

Context: CREATE TABLE Rent_Arrears (council_tax_id VARCHAR, cmi_cross_ref_id VARCHAR); CREATE TABLE Customer_Master_Index (master_customer_id VARCHAR, cmi_details VARCHAR); CREATE TABLE CMI_Cross_References (cmi_cross_ref_id VARCHAR, master_customer_id VARCHAR)

Answer: [SQL] SELECT T1.council_tax_id FROM Rent_Arrears AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id JOIN Customer_Master_Index AS T3 ON T3.master_customer_id = T2.master_customer_id WHERE T3.cmi_details <> 'Schmidt ,  Kertzmann and Lubowitz' [/SQL]


Question: What are the register ids of electoral registries that have the cross reference source system code 'Electoral' or 'Tax'?

Context: CREATE TABLE Electoral_Register (electoral_register_id VARCHAR, cmi_cross_ref_id VARCHAR); CREATE TABLE CMI_Cross_References (cmi_cross_ref_id VARCHAR, source_system_code VARCHAR)

Answer: [SQL] SELECT T1.electoral_register_id FROM Electoral_Register AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id WHERE T2.source_system_code = 'Electoral' OR T2.source_system_code = 'Tax' [/SQL]


Question: How many different source system code for the cmi cross references are there?

Context: CREATE TABLE CMI_cross_references (source_system_code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT source_system_code) FROM CMI_cross_references [/SQL]


Question: List all information about customer master index, and sort them by details in descending order.

Context: CREATE TABLE customer_master_index (cmi_details VARCHAR)

Answer: [SQL] SELECT * FROM customer_master_index ORDER BY cmi_details DESC [/SQL]


Question: List the council tax ids and their related cmi cross references of all the parking fines.

Context: CREATE TABLE parking_fines (council_tax_id VARCHAR, cmi_cross_ref_id VARCHAR)

Answer: [SQL] SELECT council_tax_id, cmi_cross_ref_id FROM parking_fines [/SQL]


Question: How many council taxes are collected for renting arrears ?

Context: CREATE TABLE rent_arrears (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM rent_arrears [/SQL]


Question: What are the distinct cross reference source system codes which are related to the master customer details 'Gottlieb, Becker and Wyman'?

Context: CREATE TABLE customer_master_index (master_customer_id VARCHAR, cmi_details VARCHAR); CREATE TABLE cmi_cross_references (source_system_code VARCHAR, master_customer_id VARCHAR)

Answer: [SQL] SELECT DISTINCT T2.source_system_code FROM customer_master_index AS T1 JOIN cmi_cross_references AS T2 ON T1.master_customer_id = T2.master_customer_id WHERE T1.cmi_details = 'Gottlieb ,  Becker and Wyman' [/SQL]


Question: Which cmi cross reference id is not related to any parking taxes?

Context: CREATE TABLE parking_fines (cmi_cross_ref_id VARCHAR); CREATE TABLE cmi_cross_references (cmi_cross_ref_id VARCHAR)

Answer: [SQL] SELECT cmi_cross_ref_id FROM cmi_cross_references EXCEPT SELECT cmi_cross_ref_id FROM parking_fines [/SQL]


Question: Which distinct source system code includes the substring 'en'?

Context: CREATE TABLE cmi_cross_references (source_system_code VARCHAR)

Answer: [SQL] SELECT DISTINCT source_system_code FROM cmi_cross_references WHERE source_system_code LIKE '%en%' [/SQL]


Question: How many parties are there?

Context: CREATE TABLE party (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM party [/SQL]


Question: List the themes of parties in ascending order of number of hosts.

Context: CREATE TABLE party (Party_Theme VARCHAR, Number_of_hosts VARCHAR)

Answer: [SQL] SELECT Party_Theme FROM party ORDER BY Number_of_hosts [/SQL]


Question: What are the themes and locations of parties?

Context: CREATE TABLE party (Party_Theme VARCHAR, LOCATION VARCHAR)

Answer: [SQL] SELECT Party_Theme, LOCATION FROM party [/SQL]


Question: Show the first year and last year of parties with theme "Spring" or "Teqnology".

Context: CREATE TABLE party (First_year VARCHAR, Last_year VARCHAR, Party_Theme VARCHAR)

Answer: [SQL] SELECT First_year, Last_year FROM party WHERE Party_Theme = "Spring" OR Party_Theme = "Teqnology" [/SQL]


Question: What is the average number of hosts for parties?

Context: CREATE TABLE party (Number_of_hosts INTEGER)

Answer: [SQL] SELECT AVG(Number_of_hosts) FROM party [/SQL]


Question: What is the location of the party with the most hosts?

Context: CREATE TABLE party (LOCATION VARCHAR, Number_of_hosts VARCHAR)

Answer: [SQL] SELECT LOCATION FROM party ORDER BY Number_of_hosts DESC LIMIT 1 [/SQL]


Question: Show different nationalities along with the number of hosts of each nationality.

Context: CREATE TABLE HOST (Nationality VARCHAR)

Answer: [SQL] SELECT Nationality, COUNT(*) FROM HOST GROUP BY Nationality [/SQL]


Question: Show the most common nationality of hosts.

Context: CREATE TABLE HOST (Nationality VARCHAR)

Answer: [SQL] SELECT Nationality FROM HOST GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the nations that have both hosts older than 45 and hosts younger than 35.

Context: CREATE TABLE HOST (Nationality VARCHAR, Age INTEGER)

Answer: [SQL] SELECT Nationality FROM HOST WHERE Age > 45 INTERSECT SELECT Nationality FROM HOST WHERE Age < 35 [/SQL]


Question: Show the themes of parties and the names of the party hosts.

Context: CREATE TABLE HOST (Name VARCHAR, Host_ID VARCHAR); CREATE TABLE party_host (Host_ID VARCHAR, Party_ID VARCHAR); CREATE TABLE party (Party_Theme VARCHAR, Party_ID VARCHAR)

Answer: [SQL] SELECT T3.Party_Theme, T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID [/SQL]


Question: Show the locations of parties and the names of the party hosts in ascending order of the age of the host.

Context: CREATE TABLE party (Location VARCHAR, Party_ID VARCHAR); CREATE TABLE HOST (Name VARCHAR, Host_ID VARCHAR, Age VARCHAR); CREATE TABLE party_host (Host_ID VARCHAR, Party_ID VARCHAR)

Answer: [SQL] SELECT T3.Location, T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID ORDER BY T2.Age [/SQL]


Question: Show the locations of parties with hosts older than 50.

Context: CREATE TABLE party (Location VARCHAR, Party_ID VARCHAR); CREATE TABLE party_host (Host_ID VARCHAR, Party_ID VARCHAR); CREATE TABLE HOST (Host_ID VARCHAR, Age INTEGER)

Answer: [SQL] SELECT T3.Location FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T2.Age > 50 [/SQL]


Question: Show the host names for parties with number of hosts greater than 20.

Context: CREATE TABLE HOST (Name VARCHAR, Host_ID VARCHAR); CREATE TABLE party_host (Host_ID VARCHAR, Party_ID VARCHAR); CREATE TABLE party (Party_ID VARCHAR, Number_of_hosts INTEGER)

Answer: [SQL] SELECT T2.Name FROM party_host AS T1 JOIN HOST AS T2 ON T1.Host_ID = T2.Host_ID JOIN party AS T3 ON T1.Party_ID = T3.Party_ID WHERE T3.Number_of_hosts > 20 [/SQL]


Question: Show the name and the nationality of the oldest host.

Context: CREATE TABLE HOST (Name VARCHAR, Nationality VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Name, Nationality FROM HOST ORDER BY Age DESC LIMIT 1 [/SQL]


Question: List the names of hosts who did not serve as a host of any party in our record.

Context: CREATE TABLE HOST (Name VARCHAR, Host_ID VARCHAR); CREATE TABLE party_host (Name VARCHAR, Host_ID VARCHAR)

Answer: [SQL] SELECT Name FROM HOST WHERE NOT Host_ID IN (SELECT Host_ID FROM party_host) [/SQL]


Question: Show all region code and region name sorted by the codes.

Context: CREATE TABLE region (region_code VARCHAR, region_name VARCHAR)

Answer: [SQL] SELECT region_code, region_name FROM region ORDER BY region_code [/SQL]


Question: List all region names in alphabetical order.

Context: CREATE TABLE region (region_name VARCHAR)

Answer: [SQL] SELECT region_name FROM region ORDER BY region_name [/SQL]


Question: Show names for all regions except for Denmark.

Answer: [SQL] SELECT region_name FROM region WHERE region_name <> 'Denmark' [/SQL]


Question: How many storms had death records?

Context: CREATE TABLE storm (Number_Deaths INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM storm WHERE Number_Deaths > 0 [/SQL]


Question: List name, dates active, and number of deaths for all storms with at least 1 death.

Context: CREATE TABLE storm (name VARCHAR, dates_active VARCHAR, number_deaths VARCHAR)

Answer: [SQL] SELECT name, dates_active, number_deaths FROM storm WHERE number_deaths >= 1 [/SQL]


Question: Show the average and maximum damage for all storms with max speed higher than 1000.

Context: CREATE TABLE storm (damage_millions_USD INTEGER, max_speed INTEGER)

Answer: [SQL] SELECT AVG(damage_millions_USD), MAX(damage_millions_USD) FROM storm WHERE max_speed > 1000 [/SQL]


Question: What is the total number of deaths and damage for all storms with a max speed greater than the average?

Context: CREATE TABLE storm (number_deaths INTEGER, damage_millions_USD INTEGER, max_speed INTEGER)

Answer: [SQL] SELECT SUM(number_deaths), SUM(damage_millions_USD) FROM storm WHERE max_speed > (SELECT AVG(max_speed) FROM storm) [/SQL]


Question: List name and damage for all storms in a descending order of max speed.

Context: CREATE TABLE storm (name VARCHAR, damage_millions_USD VARCHAR, max_speed VARCHAR)

Answer: [SQL] SELECT name, damage_millions_USD FROM storm ORDER BY max_speed DESC [/SQL]


Question: How many regions are affected?

Context: CREATE TABLE affected_region (region_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT region_id) FROM affected_region [/SQL]


Question: Show the name for regions not affected.

Context: CREATE TABLE region (region_name VARCHAR, region_id VARCHAR); CREATE TABLE affected_region (region_name VARCHAR, region_id VARCHAR)

Answer: [SQL] SELECT region_name FROM region WHERE NOT region_id IN (SELECT region_id FROM affected_region) [/SQL]


Question: Show the name for regions and the number of storms for each region.

Context: CREATE TABLE region (region_name VARCHAR, region_id VARCHAR); CREATE TABLE affected_region (region_id VARCHAR)

Answer: [SQL] SELECT T1.region_name, COUNT(*) FROM region AS T1 JOIN affected_region AS T2 ON T1.region_id = T2.region_id GROUP BY T1.region_id [/SQL]


Question: List the name for storms and the number of affected regions for each storm.

Context: CREATE TABLE affected_region (storm_id VARCHAR); CREATE TABLE storm (name VARCHAR, storm_id VARCHAR)

Answer: [SQL] SELECT T1.name, COUNT(*) FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id [/SQL]


Question: What is the storm name and max speed which affected the greatest number of regions?

Context: CREATE TABLE storm (name VARCHAR, max_speed VARCHAR, storm_id VARCHAR); CREATE TABLE affected_region (storm_id VARCHAR)

Answer: [SQL] SELECT T1.name, T1.max_speed FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the name of storms which don't have affected region in record.

Context: CREATE TABLE affected_region (name VARCHAR, storm_id VARCHAR); CREATE TABLE storm (name VARCHAR, storm_id VARCHAR)

Answer: [SQL] SELECT name FROM storm WHERE NOT storm_id IN (SELECT storm_id FROM affected_region) [/SQL]


Question: Show storm name with at least two regions and 10 cities affected.

Context: CREATE TABLE affected_region (storm_id VARCHAR, number_city_affected INTEGER); CREATE TABLE storm (name VARCHAR, storm_id VARCHAR)

Answer: [SQL] SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING COUNT(*) >= 2 INTERSECT SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING SUM(T2.number_city_affected) >= 10 [/SQL]


Question: Show all storm names except for those with at least two affected regions.

Context: CREATE TABLE storm (name VARCHAR); CREATE TABLE affected_region (storm_id VARCHAR); CREATE TABLE storm (name VARCHAR, storm_id VARCHAR)

Answer: [SQL] SELECT name FROM storm EXCEPT SELECT T1.name FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id HAVING COUNT(*) >= 2 [/SQL]


Question: What are the region names affected by the storm with a number of deaths of least 10?

Context: CREATE TABLE region (region_name VARCHAR, region_id VARCHAR); CREATE TABLE affected_region (region_id VARCHAR, storm_id VARCHAR); CREATE TABLE storm (storm_id VARCHAR, number_deaths VARCHAR)

Answer: [SQL] SELECT T2.region_name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T3.number_deaths >= 10 [/SQL]


Question: Show all storm names affecting region "Denmark".

Context: CREATE TABLE region (region_id VARCHAR, region_name VARCHAR); CREATE TABLE affected_region (region_id VARCHAR, storm_id VARCHAR); CREATE TABLE storm (name VARCHAR, storm_id VARCHAR)

Answer: [SQL] SELECT T3.name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T2.region_name = 'Denmark' [/SQL]


Question: Show the region name with at least two storms.

Answer: [SQL] SELECT T1.region_name FROM region AS T1 JOIN affected_region AS T2 ON T1.region_id = T2.region_id GROUP BY T1.region_id HAVING COUNT(*) >= 2 [/SQL]


Question: Find the names of the regions which were affected by the storm that killed the greatest number of people.

Context: CREATE TABLE region (region_name VARCHAR, region_id VARCHAR); CREATE TABLE affected_region (region_id VARCHAR, storm_id VARCHAR); CREATE TABLE storm (storm_id VARCHAR, Number_Deaths VARCHAR)

Answer: [SQL] SELECT T2.region_name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id ORDER BY T3.Number_Deaths DESC LIMIT 1 [/SQL]


Question: Find the name of the storm that affected both Afghanistan and Albania regions.

Context: CREATE TABLE storm (Name VARCHAR, storm_id VARCHAR); CREATE TABLE affected_region (region_id VARCHAR, storm_id VARCHAR); CREATE TABLE region (region_id VARCHAR, Region_name VARCHAR)

Answer: [SQL] SELECT T3.Name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T2.Region_name = 'Afghanistan' INTERSECT SELECT T3.Name FROM affected_region AS T1 JOIN region AS T2 ON T1.region_id = T2.region_id JOIN storm AS T3 ON T1.storm_id = T3.storm_id WHERE T2.Region_name = 'Albania' [/SQL]


Question: How many counties are there in total?

Context: CREATE TABLE county (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM county [/SQL]


Question: Show the county name and population of all counties.

Context: CREATE TABLE county (County_name VARCHAR, Population VARCHAR)

Answer: [SQL] SELECT County_name, Population FROM county [/SQL]


Question: Show the average population of all counties.

Context: CREATE TABLE county (Population INTEGER)

Answer: [SQL] SELECT AVG(Population) FROM county [/SQL]


Question: Return the maximum and minimum population among all counties.

Answer: [SQL] SELECT MAX(Population), MIN(Population) FROM county [/SQL]


Question: Show all the distinct districts for elections.

Context: CREATE TABLE election (District VARCHAR)

Answer: [SQL] SELECT DISTINCT District FROM election [/SQL]


Question: Show the zip code of the county with name "Howard".

Context: CREATE TABLE county (Zip_code VARCHAR, County_name VARCHAR)

Answer: [SQL] SELECT Zip_code FROM county WHERE County_name = "Howard" [/SQL]


Question: Show the delegate from district 1 in election.

Context: CREATE TABLE election (Delegate VARCHAR, District VARCHAR)

Answer: [SQL] SELECT Delegate FROM election WHERE District = 1 [/SQL]


Question: Show the delegate and committee information of elections.

Context: CREATE TABLE election (Delegate VARCHAR, Committee VARCHAR)

Answer: [SQL] SELECT Delegate, Committee FROM election [/SQL]


Question: How many distinct governors are there?

Context: CREATE TABLE party (Governor VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Governor) FROM party [/SQL]


Question: Show the lieutenant governor and comptroller from the democratic party.

Context: CREATE TABLE party (Lieutenant_Governor VARCHAR, Comptroller VARCHAR, Party VARCHAR)

Answer: [SQL] SELECT Lieutenant_Governor, Comptroller FROM party WHERE Party = "Democratic" [/SQL]


Question: In which distinct years was the governor "Eliot Spitzer"?

Context: CREATE TABLE party (YEAR VARCHAR, Governor VARCHAR)

Answer: [SQL] SELECT DISTINCT YEAR FROM party WHERE Governor = "Eliot Spitzer" [/SQL]


Question: Show all the information about election.

Context: CREATE TABLE election (Id VARCHAR)

Answer: [SQL] SELECT * FROM election [/SQL]


Question: Show the delegates and the names of county they belong to.

Context: CREATE TABLE election (Delegate VARCHAR, District VARCHAR); CREATE TABLE county (County_name VARCHAR, County_id VARCHAR)

Answer: [SQL] SELECT T2.Delegate, T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District [/SQL]


Question: Which delegates are from counties with population smaller than 100000?

Context: CREATE TABLE election (Delegate VARCHAR, District VARCHAR); CREATE TABLE county (County_id VARCHAR, Population INTEGER)

Answer: [SQL] SELECT T2.Delegate FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population < 100000 [/SQL]


Question: How many distinct delegates are from counties with population larger than 50000?

Answer: [SQL] SELECT COUNT(DISTINCT T2.Delegate) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population > 50000 [/SQL]


Question: What are the names of the county that the delegates on "Appropriations" committee belong to?

Context: CREATE TABLE election (District VARCHAR, Committee VARCHAR); CREATE TABLE county (County_name VARCHAR, County_id VARCHAR)

Answer: [SQL] SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T2.Committee = "Appropriations" [/SQL]


Question: Show the delegates and the names of the party they belong to.

Context: CREATE TABLE election (Delegate VARCHAR, Party VARCHAR); CREATE TABLE party (Party VARCHAR, Party_ID VARCHAR)

Answer: [SQL] SELECT T1.Delegate, T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID [/SQL]


Question: Who were the governors of the parties associated with delegates from district 1?

Context: CREATE TABLE party (Governor VARCHAR, Party_ID VARCHAR); CREATE TABLE election (Party VARCHAR, District VARCHAR)

Answer: [SQL] SELECT T2.Governor FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.District = 1 [/SQL]


Question: Who were the comptrollers of the parties associated with the delegates from district 1 or district 2?

Context: CREATE TABLE party (Comptroller VARCHAR, Party_ID VARCHAR); CREATE TABLE election (Party VARCHAR, District VARCHAR)

Answer: [SQL] SELECT T2.Comptroller FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.District = 1 OR T1.District = 2 [/SQL]


Question: Return all the committees that have delegates from Democratic party.

Context: CREATE TABLE election (Committee VARCHAR, Party VARCHAR); CREATE TABLE party (Party_ID VARCHAR, Party VARCHAR)

Answer: [SQL] SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Democratic" [/SQL]


Question: Show the name of each county along with the corresponding number of delegates from that county.

Context: CREATE TABLE election (District VARCHAR); CREATE TABLE county (County_name VARCHAR, County_id VARCHAR)

Answer: [SQL] SELECT T1.County_name, COUNT(*) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District GROUP BY T1.County_id [/SQL]


Question: Show the name of each party and the corresponding number of delegates from that party.

Context: CREATE TABLE election (Party VARCHAR); CREATE TABLE party (Party VARCHAR, Party_ID VARCHAR)

Answer: [SQL] SELECT T2.Party, COUNT(*) FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party [/SQL]


Question: Return the names of all counties sorted by population in ascending order.

Context: CREATE TABLE county (County_name VARCHAR, Population VARCHAR)

Answer: [SQL] SELECT County_name FROM county ORDER BY Population [/SQL]


Question: Return the names of all counties sorted by county name in descending alphabetical order.

Context: CREATE TABLE county (County_name VARCHAR)

Answer: [SQL] SELECT County_name FROM county ORDER BY County_name DESC [/SQL]


Question: Show the name of the county with the biggest population.

Answer: [SQL] SELECT County_name FROM county ORDER BY Population DESC LIMIT 1 [/SQL]


Question: Show the 3 counties with the smallest population.

Answer: [SQL] SELECT County_name FROM county ORDER BY Population LIMIT 3 [/SQL]


Question: Show the names of counties that have at least two delegates.

Answer: [SQL] SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District GROUP BY T1.County_id HAVING COUNT(*) >= 2 [/SQL]


Question: Show the name of the party that has at least two records.

Context: CREATE TABLE party (Party VARCHAR)

Answer: [SQL] SELECT Party FROM party GROUP BY Party HAVING COUNT(*) >= 2 [/SQL]


Question: Show the name of the party that has the most delegates.

Answer: [SQL] SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the people that have been governor the most times.

Context: CREATE TABLE party (Governor VARCHAR)

Answer: [SQL] SELECT Governor FROM party GROUP BY Governor ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the people that have been comptroller the most times and the corresponding number of times.

Context: CREATE TABLE party (Comptroller VARCHAR)

Answer: [SQL] SELECT Comptroller, COUNT(*) FROM party GROUP BY Comptroller ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the names of parties that do not have delegates in election?

Context: CREATE TABLE election (Party VARCHAR, Party_ID VARCHAR); CREATE TABLE party (Party VARCHAR, Party_ID VARCHAR)

Answer: [SQL] SELECT Party FROM party WHERE NOT Party_ID IN (SELECT Party FROM election) [/SQL]


Question: What are the names of parties that have both delegates on "Appropriations" committee and

Context: CREATE TABLE election (Party VARCHAR, Committee VARCHAR); CREATE TABLE party (Party VARCHAR, Party_ID VARCHAR)

Answer: [SQL] SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.Committee = "Appropriations" INTERSECT SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.Committee = "Economic Matters" [/SQL]


Question: Which committees have delegates from both democratic party and liberal party?

Answer: [SQL] SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Democratic" INTERSECT SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T2.Party = "Liberal" [/SQL]


Question: How many journalists are there?

Context: CREATE TABLE journalist (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM journalist [/SQL]


Question: List the names of journalists in ascending order of years working.

Context: CREATE TABLE journalist (Name VARCHAR, Years_working VARCHAR)

Answer: [SQL] SELECT Name FROM journalist ORDER BY Years_working [/SQL]


Question: What are the nationalities and ages of journalists?

Context: CREATE TABLE journalist (Nationality VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Nationality, Age FROM journalist [/SQL]


Question: Show the names of journalists from "England" or "Wales".

Context: CREATE TABLE journalist (Name VARCHAR, Nationality VARCHAR)

Answer: [SQL] SELECT Name FROM journalist WHERE Nationality = "England" OR Nationality = "Wales" [/SQL]


Question: What is the average number of years spent working as a journalist?

Context: CREATE TABLE journalist (Years_working INTEGER)

Answer: [SQL] SELECT AVG(Years_working) FROM journalist [/SQL]


Question: What is the nationality of the journalist with the largest number of years working?

Context: CREATE TABLE journalist (Nationality VARCHAR, Years_working VARCHAR)

Answer: [SQL] SELECT Nationality FROM journalist ORDER BY Years_working DESC LIMIT 1 [/SQL]


Question: Show the different nationalities and the number of journalists of each nationality.

Context: CREATE TABLE journalist (Nationality VARCHAR)

Answer: [SQL] SELECT Nationality, COUNT(*) FROM journalist GROUP BY Nationality [/SQL]


Question: Show the most common nationality for journalists.

Answer: [SQL] SELECT Nationality FROM journalist GROUP BY Nationality ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the nations that have both journalists with more than 10 years of working and journalists with less than 3 years of working.

Context: CREATE TABLE journalist (Nationality VARCHAR, Years_working INTEGER)

Answer: [SQL] SELECT Nationality FROM journalist WHERE Years_working > 10 INTERSECT SELECT Nationality FROM journalist WHERE Years_working < 3 [/SQL]


Question: Show the dates, places, and names of events in descending order of the attendance.

Context: CREATE TABLE event (Date VARCHAR, Name VARCHAR, venue VARCHAR, Event_Attendance VARCHAR)

Answer: [SQL] SELECT Date, Name, venue FROM event ORDER BY Event_Attendance DESC [/SQL]


Question: Show the names of journalists and the dates of the events they reported.

Context: CREATE TABLE journalist (Name VARCHAR, journalist_ID VARCHAR); CREATE TABLE news_report (Event_ID VARCHAR, journalist_ID VARCHAR); CREATE TABLE event (Date VARCHAR, Event_ID VARCHAR)

Answer: [SQL] SELECT T3.Name, T2.Date FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID [/SQL]


Question: Show the names of journalists and the names of the events they reported in ascending order

Context: CREATE TABLE journalist (Name VARCHAR, journalist_ID VARCHAR); CREATE TABLE news_report (Event_ID VARCHAR, journalist_ID VARCHAR); CREATE TABLE event (Name VARCHAR, Event_ID VARCHAR, Event_Attendance VARCHAR)

Answer: [SQL] SELECT T3.Name, T2.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID ORDER BY T2.Event_Attendance [/SQL]


Question: Show the names of journalists and the number of events they reported.

Context: CREATE TABLE journalist (Name VARCHAR, journalist_ID VARCHAR); CREATE TABLE news_report (Event_ID VARCHAR, journalist_ID VARCHAR); CREATE TABLE event (Event_ID VARCHAR)

Answer: [SQL] SELECT T3.Name, COUNT(*) FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name [/SQL]


Question: Show the names of journalists that have reported more than one event.

Answer: [SQL] SELECT T3.Name FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name HAVING COUNT(*) > 1 [/SQL]


Question: List the names of journalists who have not reported any event.

Context: CREATE TABLE journalist (Name VARCHAR, journalist_ID VARCHAR); CREATE TABLE news_report (Name VARCHAR, journalist_ID VARCHAR)

Answer: [SQL] SELECT Name FROM journalist WHERE NOT journalist_ID IN (SELECT journalist_ID FROM news_report) [/SQL]


Question: what are the average and maximum attendances of all events?

Context: CREATE TABLE event (Event_Attendance INTEGER)

Answer: [SQL] SELECT AVG(Event_Attendance), MAX(Event_Attendance) FROM event [/SQL]


Question: Find the average age and experience working length of journalists working on different role type.

Context: CREATE TABLE news_report (work_type VARCHAR, journalist_id VARCHAR); CREATE TABLE journalist (age INTEGER, journalist_id VARCHAR)

Answer: [SQL] SELECT AVG(t1.age), AVG(Years_working), t2.work_type FROM journalist AS t1 JOIN news_report AS t2 ON t1.journalist_id = t2.journalist_id GROUP BY t2.work_type [/SQL]


Question: List the event venues and names that have the top 2 most number of people attended.

Context: CREATE TABLE event (venue VARCHAR, name VARCHAR, Event_Attendance VARCHAR)

Answer: [SQL] SELECT venue, name FROM event ORDER BY Event_Attendance DESC LIMIT 2 [/SQL]


Question: Show me all the restaurants.

Context: CREATE TABLE Restaurant (ResName VARCHAR)

Answer: [SQL] SELECT ResName FROM Restaurant [/SQL]


Question: What is the address of the restaurant Subway?

Context: CREATE TABLE Restaurant (Address VARCHAR, ResName VARCHAR)

Answer: [SQL] SELECT Address FROM Restaurant WHERE ResName = "Subway" [/SQL]


Question: What is the rating of the restaurant Subway?

Context: CREATE TABLE Restaurant (Rating VARCHAR, ResName VARCHAR)

Answer: [SQL] SELECT Rating FROM Restaurant WHERE ResName = "Subway" [/SQL]


Question: List all restaurant types.

Context: CREATE TABLE Restaurant_Type (ResTypeName VARCHAR)

Answer: [SQL] SELECT ResTypeName FROM Restaurant_Type [/SQL]


Question: What is the description of the restaurant type Sandwich?

Context: CREATE TABLE Restaurant_Type (ResTypeDescription VARCHAR, ResTypeName VARCHAR)

Answer: [SQL] SELECT ResTypeDescription FROM Restaurant_Type WHERE ResTypeName = "Sandwich" [/SQL]


Question: Which restaurants have highest rating? List the restaurant name and its rating.

Context: CREATE TABLE Restaurant (ResName VARCHAR, Rating VARCHAR)

Answer: [SQL] SELECT ResName, Rating FROM Restaurant ORDER BY Rating DESC LIMIT 1 [/SQL]


Question: What is the age of student Linda Smith?

Context: CREATE TABLE Student (Age VARCHAR, Fname VARCHAR, Lname VARCHAR)

Answer: [SQL] SELECT Age FROM Student WHERE Fname = "Linda" AND Lname = "Smith" [/SQL]


Question: What is the gender of the student Linda Smith?

Context: CREATE TABLE Student (Sex VARCHAR, Fname VARCHAR, Lname VARCHAR)

Answer: [SQL] SELECT Sex FROM Student WHERE Fname = "Linda" AND Lname = "Smith" [/SQL]


Question: List all students' first names and last names who majored in 600.

Context: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Major VARCHAR)

Answer: [SQL] SELECT Fname, Lname FROM Student WHERE Major = 600 [/SQL]


Question: Which city does student Linda Smith live in?

Context: CREATE TABLE Student (city_code VARCHAR, Fname VARCHAR, Lname VARCHAR)

Answer: [SQL] SELECT city_code FROM Student WHERE Fname = "Linda" AND Lname = "Smith" [/SQL]


Question: Advisor 1121 has how many students?

Context: CREATE TABLE Student (Advisor VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Student WHERE Advisor = 1121 [/SQL]


Question: Which Advisor has most of students? List advisor and the number of students.

Context: CREATE TABLE Student (Advisor VARCHAR)

Answer: [SQL] SELECT Advisor, COUNT(*) FROM Student GROUP BY Advisor ORDER BY COUNT(Advisor) DESC LIMIT 1 [/SQL]


Question: Which major has least number of students? List the major and the number of students.

Context: CREATE TABLE Student (Major VARCHAR)

Answer: [SQL] SELECT Major, COUNT(*) FROM Student GROUP BY Major ORDER BY COUNT(Major) LIMIT 1 [/SQL]


Question: Which major has between 2 and 30 number of students? List major and the number of students.

Context: CREATE TABLE Student (Major VARCHAR)

Answer: [SQL] SELECT Major, COUNT(*) FROM Student GROUP BY Major HAVING COUNT(Major) BETWEEN 2 AND 30 [/SQL]


Question: Which student's age is older than 18 and is majoring in 600? List each student's first and last name.

Context: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Age VARCHAR, Major VARCHAR)

Answer: [SQL] SELECT Fname, Lname FROM Student WHERE Age > 18 AND Major = 600 [/SQL]


Question: List all female students age is older than 18 who is not majoring in 600. List students' first name and last name.

Context: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Sex VARCHAR, Age VARCHAR, Major VARCHAR)

Answer: [SQL] SELECT Fname, Lname FROM Student WHERE Age > 18 AND Major <> 600 AND Sex = 'F' [/SQL]


Question: How many restaurant is the Sandwich type restaurant?

Context: CREATE TABLE Type_Of_Restaurant (Id VARCHAR); CREATE TABLE Restaurant (Id VARCHAR); CREATE TABLE Restaurant_Type (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Restaurant JOIN Type_Of_Restaurant ON Restaurant.ResID = Type_Of_Restaurant.ResID JOIN Restaurant_Type ON Type_Of_Restaurant.ResTypeID = Restaurant_Type.ResTypeID GROUP BY Type_Of_Restaurant.ResTypeID HAVING Restaurant_Type.ResTypeName = 'Sandwich' [/SQL]


Question: How long does student Linda Smith spend on the restaurant in total?

Context: CREATE TABLE Visits_Restaurant (Spent INTEGER); CREATE TABLE Student (Spent INTEGER)

Answer: [SQL] SELECT SUM(Spent) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" [/SQL]


Question: How many times has the student Linda Smith visited Subway?

Context: CREATE TABLE Visits_Restaurant (Id VARCHAR); CREATE TABLE Student (Id VARCHAR); CREATE TABLE Restaurant (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" AND Restaurant.ResName = "Subway" [/SQL]


Question: When did Linda Smith visit Subway?

Context: CREATE TABLE Restaurant (TIME VARCHAR); CREATE TABLE Visits_Restaurant (TIME VARCHAR); CREATE TABLE Student (TIME VARCHAR)

Answer: [SQL] SELECT TIME FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" AND Restaurant.ResName = "Subway" [/SQL]


Question: At which restaurant did the students spend the least amount of time? List restaurant and the time students spent on in total.

Context: CREATE TABLE Visits_Restaurant (Id VARCHAR); CREATE TABLE Restaurant (Id VARCHAR)

Answer: [SQL] SELECT Restaurant.ResName, SUM(Visits_Restaurant.Spent) FROM Visits_Restaurant JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID GROUP BY Restaurant.ResID ORDER BY SUM(Visits_Restaurant.Spent) LIMIT 1 [/SQL]


Question: Which student visited restaurant most often? List student's first name and last name.

Context: CREATE TABLE Visits_Restaurant (Id VARCHAR); CREATE TABLE Student (Id VARCHAR)

Answer: [SQL] SELECT Student.Fname, Student.Lname FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID GROUP BY Student.StuID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the ids of orders whose status is 'Success'.

Context: CREATE TABLE actual_orders (actual_order_id VARCHAR, order_status_code VARCHAR)

Answer: [SQL] SELECT actual_order_id FROM actual_orders WHERE order_status_code = 'Success' [/SQL]


Question: Find the name and price of the product that has been ordered the greatest number of times.

Context: CREATE TABLE products (product_name VARCHAR, product_price VARCHAR, product_id VARCHAR); CREATE TABLE regular_order_products (product_id VARCHAR)

Answer: [SQL] SELECT t1.product_name, t1.product_price FROM products AS t1 JOIN regular_order_products AS t2 ON t1.product_id = t2.product_id GROUP BY t2.product_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the number of customers in total.

Context: CREATE TABLE customers (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers [/SQL]


Question: How many different payment methods are there?

Context: CREATE TABLE customers (payment_method VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT payment_method) FROM customers [/SQL]


Question: Show the details of all trucks in the order of their license number.

Context: CREATE TABLE trucks (truck_details VARCHAR, truck_licence_number VARCHAR)

Answer: [SQL] SELECT truck_details FROM trucks ORDER BY truck_licence_number [/SQL]


Question: Find the name of the most expensive product.

Context: CREATE TABLE products (product_name VARCHAR, product_price VARCHAR)

Answer: [SQL] SELECT product_name FROM products ORDER BY product_price DESC LIMIT 1 [/SQL]


Question: Find the names of customers who are not living in the state of California.

Context: CREATE TABLE customer_addresses (customer_id VARCHAR, address_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR); CREATE TABLE addresses (address_id VARCHAR, state_province_county VARCHAR)

Answer: [SQL] SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = 'California' [/SQL]


Question: List the names and emails of customers who payed by Visa card.

Context: CREATE TABLE customers (customer_email VARCHAR, customer_name VARCHAR, payment_method VARCHAR)

Answer: [SQL] SELECT customer_email, customer_name FROM customers WHERE payment_method = 'Visa' [/SQL]