Question: How many heads of the departments are older than 56 ?

Context: CREATE TABLE head (age INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM head WHERE age > 56 [/SQL]


Question: List the name, born state and age of the heads of departments ordered by age.

Context: CREATE TABLE head (name VARCHAR, born_state VARCHAR, age VARCHAR)

Answer: [SQL] SELECT name, born_state, age FROM head ORDER BY age [/SQL]


Question: List the creation year, name and budget of each department.

Context: CREATE TABLE department (creation VARCHAR, name VARCHAR, budget_in_billions VARCHAR)

Answer: [SQL] SELECT creation, name, budget_in_billions FROM department [/SQL]


Question: What are the maximum and minimum budget of the departments?

Context: CREATE TABLE department (budget_in_billions INTEGER)

Answer: [SQL] SELECT MAX(budget_in_billions), MIN(budget_in_billions) FROM department [/SQL]


Question: What is the average number of employees of the departments whose rank is between 10 and 15?

Context: CREATE TABLE department (num_employees INTEGER, ranking INTEGER)

Answer: [SQL] SELECT AVG(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15 [/SQL]


Question: What are the names of the heads who are born outside the California state?

Context: CREATE TABLE head (name VARCHAR, born_state VARCHAR)

Answer: [SQL] SELECT name FROM head WHERE born_state <> 'California' [/SQL]


Question: What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?

Context: CREATE TABLE department (creation VARCHAR, department_id VARCHAR); CREATE TABLE management (department_id VARCHAR, head_id VARCHAR); CREATE TABLE head (head_id VARCHAR, born_state VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T3.born_state = 'Alabama' [/SQL]


Question: What are the names of the states where at least 3 heads were born?

Context: CREATE TABLE head (born_state VARCHAR)

Answer: [SQL] SELECT born_state FROM head GROUP BY born_state HAVING COUNT(*) >= 3 [/SQL]


Question: In which year were most departments established?

Context: CREATE TABLE department (creation VARCHAR)

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


Question: Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'?

Context: CREATE TABLE management (department_id VARCHAR, temporary_acting VARCHAR); CREATE TABLE department (name VARCHAR, num_employees VARCHAR, department_id VARCHAR)

Answer: [SQL] SELECT T1.name, T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id WHERE T2.temporary_acting = 'Yes' [/SQL]


Question: How many acting statuses are there?

Context: CREATE TABLE management (temporary_acting VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT temporary_acting) FROM management [/SQL]


Question: How many departments are led by heads who are not mentioned?

Context: CREATE TABLE management (department_id VARCHAR); CREATE TABLE department (department_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM department WHERE NOT department_id IN (SELECT department_id FROM management) [/SQL]


Question: What are the distinct ages of the heads who are acting?

Context: CREATE TABLE head (age VARCHAR, head_id VARCHAR); CREATE TABLE management (head_id VARCHAR, temporary_acting VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id = T2.head_id WHERE T2.temporary_acting = 'Yes' [/SQL]


Question: List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.

Context: CREATE TABLE management (department_id VARCHAR, head_id VARCHAR); CREATE TABLE head (born_state VARCHAR, head_id VARCHAR); CREATE TABLE department (department_id VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Homeland Security' [/SQL]


Question: Which department has more than 1 head at a time? List the id, name and the number of heads.

Context: CREATE TABLE management (department_id VARCHAR); CREATE TABLE department (department_id VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T1.department_id, T1.name, COUNT(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id = T2.department_id GROUP BY T1.department_id HAVING COUNT(*) > 1 [/SQL]


Question: Which head's name has the substring 'Ha'? List the id and name.

Context: CREATE TABLE head (head_id VARCHAR, name VARCHAR)

Answer: [SQL] SELECT head_id, name FROM head WHERE name LIKE '%Ha%' [/SQL]


Question: How many farms are there?

Context: CREATE TABLE farm (Id VARCHAR)

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


Question: List the total number of horses on farms in ascending order.

Context: CREATE TABLE farm (Total_Horses VARCHAR)

Answer: [SQL] SELECT Total_Horses FROM farm ORDER BY Total_Horses [/SQL]


Question: What are the hosts of competitions whose theme is not "Aliens"?

Context: CREATE TABLE farm_competition (Hosts VARCHAR, Theme VARCHAR)

Answer: [SQL] SELECT Hosts FROM farm_competition WHERE Theme <> 'Aliens' [/SQL]


Question: What are the themes of farm competitions sorted by year in ascending order?

Context: CREATE TABLE farm_competition (Theme VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT Theme FROM farm_competition ORDER BY YEAR [/SQL]


Question: What is the average number of working horses of farms with more than 5000 total number of horses?

Context: CREATE TABLE farm (Working_Horses INTEGER, Total_Horses INTEGER)

Answer: [SQL] SELECT AVG(Working_Horses) FROM farm WHERE Total_Horses > 5000 [/SQL]


Question: What are the maximum and minimum number of cows across all farms.

Context: CREATE TABLE farm (Cows INTEGER)

Answer: [SQL] SELECT MAX(Cows), MIN(Cows) FROM farm [/SQL]


Question: How many different statuses do cities have?

Context: CREATE TABLE city (Status VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Status) FROM city [/SQL]


Question: List official names of cities in descending order of population.

Context: CREATE TABLE city (Official_Name VARCHAR, Population VARCHAR)

Answer: [SQL] SELECT Official_Name FROM city ORDER BY Population DESC [/SQL]


Question: List the official name and status of the city with the largest population.

Context: CREATE TABLE city (Official_Name VARCHAR, Status VARCHAR, Population VARCHAR)

Answer: [SQL] SELECT Official_Name, Status FROM city ORDER BY Population DESC LIMIT 1 [/SQL]


Question: Show the years and the official names of the host cities of competitions.

Context: CREATE TABLE city (Official_Name VARCHAR, City_ID VARCHAR); CREATE TABLE farm_competition (Year VARCHAR, Host_city_ID VARCHAR)

Answer: [SQL] SELECT T2.Year, T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID [/SQL]


Question: Show the official names of the cities that have hosted more than one competition.

Context: CREATE TABLE farm_competition (Host_city_ID VARCHAR); CREATE TABLE city (Official_Name VARCHAR, City_ID VARCHAR)

Answer: [SQL] SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1 [/SQL]


Question: Show the status of the city that has hosted the greatest number of competitions.

Context: CREATE TABLE city (Status VARCHAR, City_ID VARCHAR); CREATE TABLE farm_competition (Host_city_ID VARCHAR)

Answer: [SQL] SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Please show the themes of competitions with host cities having populations larger than 1000.

Context: CREATE TABLE city (City_ID VARCHAR, Population INTEGER); CREATE TABLE farm_competition (Theme VARCHAR, Host_city_ID VARCHAR)

Answer: [SQL] SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000 [/SQL]


Question: Please show the different statuses of cities and the average population of cities with each status.

Context: CREATE TABLE city (Status VARCHAR, Population INTEGER)

Answer: [SQL] SELECT Status, AVG(Population) FROM city GROUP BY Status [/SQL]


Question: Please show the different statuses, ordered by the number of cities that have each.

Context: CREATE TABLE city (Status VARCHAR)

Answer: [SQL] SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) [/SQL]


Question: List the most common type of Status across cities.

Context: CREATE TABLE city (Status VARCHAR)

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


Question: List the official names of cities that have not held any competition.

Context: CREATE TABLE farm_competition (Official_Name VARCHAR, City_ID VARCHAR, Host_city_ID VARCHAR); CREATE TABLE city (Official_Name VARCHAR, City_ID VARCHAR, Host_city_ID VARCHAR)

Answer: [SQL] SELECT Official_Name FROM city WHERE NOT City_ID IN (SELECT Host_city_ID FROM farm_competition) [/SQL]


Question: Show the status shared by cities with population bigger than 1500 and smaller than 500.

Answer: [SQL] SELECT Status FROM city WHERE Population > 1500 INTERSECT SELECT Status FROM city WHERE Population < 500 [/SQL]


Question: Find the official names of cities with population bigger than 1500 or smaller than 500.

Answer: [SQL] SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500 [/SQL]


Question: Show the census ranking of cities whose status are not "Village".

Context: CREATE TABLE city (Census_Ranking VARCHAR, Status VARCHAR)

Answer: [SQL] SELECT Census_Ranking FROM city WHERE Status <> "Village" [/SQL]


Question: which course has most number of registered students?

Context: CREATE TABLE courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE student_course_registrations (course_Id VARCHAR)

Answer: [SQL] SELECT T1.course_name FROM courses AS T1 JOIN student_course_registrations AS T2 ON T1.course_id = T2.course_Id GROUP BY T1.course_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: what is id of students who registered some courses but the least number of courses in these students?

Context: CREATE TABLE student_course_registrations (student_id VARCHAR)

Answer: [SQL] SELECT student_id FROM student_course_registrations GROUP BY student_id ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: what are the first name and last name of all candidates?

Context: CREATE TABLE candidates (candidate_id VARCHAR); CREATE TABLE people (first_name VARCHAR, last_name VARCHAR, person_id VARCHAR)

Answer: [SQL] SELECT T2.first_name, T2.last_name FROM candidates AS T1 JOIN people AS T2 ON T1.candidate_id = T2.person_id [/SQL]


Question: List the id of students who never attends courses?

Context: CREATE TABLE student_course_attendance (student_id VARCHAR); CREATE TABLE students (student_id VARCHAR)

Answer: [SQL] SELECT student_id FROM students WHERE NOT student_id IN (SELECT student_id FROM student_course_attendance) [/SQL]


Question: List the id of students who attended some courses?

Context: CREATE TABLE student_course_attendance (student_id VARCHAR)

Answer: [SQL] SELECT student_id FROM student_course_attendance [/SQL]


Question: What are the ids of all students for courses and what are the names of those courses?

Context: CREATE TABLE courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE student_course_registrations (student_id VARCHAR, course_id VARCHAR)

Answer: [SQL] SELECT T1.student_id, T2.course_name FROM student_course_registrations AS T1 JOIN courses AS T2 ON T1.course_id = T2.course_id [/SQL]


Question: What is detail of the student who most recently registered course?

Context: CREATE TABLE student_course_registrations (student_id VARCHAR, registration_date VARCHAR); CREATE TABLE students (student_details VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT T2.student_details FROM student_course_registrations AS T1 JOIN students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.registration_date DESC LIMIT 1 [/SQL]


Question: How many students attend course English?

Context: CREATE TABLE student_course_attendance (course_id VARCHAR); CREATE TABLE courses (course_id VARCHAR, course_name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "English" [/SQL]


Question: How many courses do the student whose id is 171 attend?

Context: CREATE TABLE courses (course_id VARCHAR); CREATE TABLE student_course_attendance (course_id VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T2.student_id = 171 [/SQL]


Question: Find id of the candidate whose email is stanley.monahan@example.org?

Context: CREATE TABLE candidates (candidate_id VARCHAR); CREATE TABLE people (person_id VARCHAR, email_address VARCHAR)

Answer: [SQL] SELECT T2.candidate_id FROM people AS T1 JOIN candidates AS T2 ON T1.person_id = T2.candidate_id WHERE T1.email_address = "stanley.monahan@example.org" [/SQL]


Question: Find id of the candidate who most recently accessed the course?

Context: CREATE TABLE candidate_assessments (candidate_id VARCHAR, assessment_date VARCHAR)

Answer: [SQL] SELECT candidate_id FROM candidate_assessments ORDER BY assessment_date DESC LIMIT 1 [/SQL]


Question: What is detail of the student who registered the most number of courses?

Context: CREATE TABLE students (student_details VARCHAR, student_id VARCHAR); CREATE TABLE student_course_registrations (student_id VARCHAR)

Answer: [SQL] SELECT T1.student_details FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the id of students who registered some courses and the number of their registered courses?

Context: CREATE TABLE students (student_id VARCHAR); CREATE TABLE student_course_registrations (student_id VARCHAR)

Answer: [SQL] SELECT T1.student_id, COUNT(*) FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id [/SQL]


Question: How many registed students do each course have? List course name and the number of their registered students?

Context: CREATE TABLE students (student_id VARCHAR); CREATE TABLE courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE student_course_registrations (course_id VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT T3.course_name, COUNT(*) FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id JOIN courses AS T3 ON T2.course_id = T3.course_id GROUP BY T2.course_id [/SQL]


Question: Find id of candidates whose assessment code is "Pass"?

Context: CREATE TABLE candidate_assessments (candidate_id VARCHAR, asessment_outcome_code VARCHAR)

Answer: [SQL] SELECT candidate_id FROM candidate_assessments WHERE asessment_outcome_code = "Pass" [/SQL]


Question: Find the cell mobile number of the candidates whose assessment code is "Fail"?

Context: CREATE TABLE candidates (candidate_id VARCHAR); CREATE TABLE people (cell_mobile_number VARCHAR, person_id VARCHAR); CREATE TABLE candidate_assessments (candidate_id VARCHAR, asessment_outcome_code VARCHAR)

Answer: [SQL] SELECT T3.cell_mobile_number FROM candidates AS T1 JOIN candidate_assessments AS T2 ON T1.candidate_id = T2.candidate_id JOIN people AS T3 ON T1.candidate_id = T3.person_id WHERE T2.asessment_outcome_code = "Fail" [/SQL]


Question: What are the id of students who registered course 301?

Context: CREATE TABLE student_course_attendance (student_id VARCHAR, course_id VARCHAR)

Answer: [SQL] SELECT student_id FROM student_course_attendance WHERE course_id = 301 [/SQL]


Question: What is the id of the student who most recently registered course 301?

Context: CREATE TABLE student_course_attendance (student_id VARCHAR, course_id VARCHAR, date_of_attendance VARCHAR)

Answer: [SQL] SELECT student_id FROM student_course_attendance WHERE course_id = 301 ORDER BY date_of_attendance DESC LIMIT 1 [/SQL]


Question: Find distinct cities of addresses of people?

Context: CREATE TABLE addresses (city VARCHAR, address_id VARCHAR); CREATE TABLE people_addresses (address_id VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id [/SQL]


Question: Find distinct cities of address of students?

Context: CREATE TABLE students (student_id VARCHAR); CREATE TABLE addresses (city VARCHAR, address_id VARCHAR); CREATE TABLE people_addresses (address_id VARCHAR, person_id VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id JOIN students AS T3 ON T2.person_id = T3.student_id [/SQL]


Question: List the names of courses in alphabetical order?

Context: CREATE TABLE courses (course_name VARCHAR)

Answer: [SQL] SELECT course_name FROM courses ORDER BY course_name [/SQL]


Question: List the first names of people in alphabetical order?

Context: CREATE TABLE people (first_name VARCHAR)

Answer: [SQL] SELECT first_name FROM people ORDER BY first_name [/SQL]


Question: What are the id of students who registered courses or attended courses?

Context: CREATE TABLE student_course_attendance (student_id VARCHAR); CREATE TABLE student_course_registrations (student_id VARCHAR)

Answer: [SQL] SELECT student_id FROM student_course_registrations UNION SELECT student_id FROM student_course_attendance [/SQL]


Question: Find the id of courses which are registered or attended by student whose id is 121?

Context: CREATE TABLE student_course_attendance (course_id VARCHAR, student_id VARCHAR); CREATE TABLE student_course_registrations (course_id VARCHAR, student_id VARCHAR)

Answer: [SQL] SELECT course_id FROM student_course_registrations WHERE student_id = 121 UNION SELECT course_id FROM student_course_attendance WHERE student_id = 121 [/SQL]


Question: What are all info of students who registered courses but not attended courses?

Answer: [SQL] SELECT * FROM student_course_registrations WHERE NOT student_id IN (SELECT student_id FROM student_course_attendance) [/SQL]


Question: List the id of students who registered course statistics in the order of registration date.

Context: CREATE TABLE student_course_registrations (student_id VARCHAR, course_id VARCHAR, registration_date VARCHAR); CREATE TABLE courses (course_id VARCHAR, course_name VARCHAR)

Answer: [SQL] SELECT T2.student_id FROM courses AS T1 JOIN student_course_registrations AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "statistics" ORDER BY T2.registration_date [/SQL]


Question: List the id of students who attended  statistics courses in the order of attendance date.

Context: CREATE TABLE student_course_attendance (student_id VARCHAR, course_id VARCHAR, date_of_attendance VARCHAR); CREATE TABLE courses (course_id VARCHAR, course_name VARCHAR)

Answer: [SQL] SELECT T2.student_id FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "statistics" ORDER BY T2.date_of_attendance [/SQL]


Question: Give me the dates when the max temperature was higher than 85.

Context: CREATE TABLE weather (date VARCHAR, max_temperature_f INTEGER)

Answer: [SQL] SELECT date FROM weather WHERE max_temperature_f > 85 [/SQL]


Question: What are the names of stations that have latitude lower than 37.5?

Context: CREATE TABLE station (name VARCHAR, lat INTEGER)

Answer: [SQL] SELECT name FROM station WHERE lat < 37.5 [/SQL]


Question: For each city, return the highest latitude among its stations.

Context: CREATE TABLE station (city VARCHAR, lat INTEGER)

Answer: [SQL] SELECT city, MAX(lat) FROM station GROUP BY city [/SQL]


Question: Give me the start station and end station for the trips with the three oldest id.

Context: CREATE TABLE trip (start_station_name VARCHAR, end_station_name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT start_station_name, end_station_name FROM trip ORDER BY id LIMIT 3 [/SQL]


Question: What is the average latitude and longitude of stations located in San Jose city?

Context: CREATE TABLE station (lat INTEGER, long INTEGER, city VARCHAR)

Answer: [SQL] SELECT AVG(lat), AVG(long) FROM station WHERE city = "San Jose" [/SQL]


Question: What is the id of the trip that has the shortest duration?

Context: CREATE TABLE trip (id VARCHAR, duration VARCHAR)

Answer: [SQL] SELECT id FROM trip ORDER BY duration LIMIT 1 [/SQL]


Question: What is the total and maximum duration of trips with bike id 636?

Context: CREATE TABLE trip (duration INTEGER, bike_id VARCHAR)

Answer: [SQL] SELECT SUM(duration), MAX(duration) FROM trip WHERE bike_id = 636 [/SQL]


Question: For each zip code, return the average mean temperature of August there.

Context: CREATE TABLE weather (zip_code VARCHAR, mean_temperature_f INTEGER, date VARCHAR)

Answer: [SQL] SELECT zip_code, AVG(mean_temperature_f) FROM weather WHERE date LIKE "8/%" GROUP BY zip_code [/SQL]


Question: From the trip record, find the number of unique bikes.

Context: CREATE TABLE trip (bike_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT bike_id) FROM trip [/SQL]


Question: What is the number of distinct cities the stations are located at?

Context: CREATE TABLE station (city VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT city) FROM station [/SQL]


Question: How many stations does Mountain View city has?

Context: CREATE TABLE station (city VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM station WHERE city = "Mountain View" [/SQL]


Question: Return the unique name for stations that have ever had 7 bikes available.

Context: CREATE TABLE station (name VARCHAR, id VARCHAR); CREATE TABLE status (station_id VARCHAR, bikes_available VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available = 7 [/SQL]


Question: Which start station had the most trips starting from August? Give me the name and id of the station.

Context: CREATE TABLE trip (start_station_name VARCHAR, start_station_id VARCHAR, start_date VARCHAR)

Answer: [SQL] SELECT start_station_name, start_station_id FROM trip WHERE start_date LIKE "8/%" GROUP BY start_station_name ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which bike traveled the most often in zip code 94002?

Context: CREATE TABLE trip (bike_id VARCHAR, zip_code VARCHAR)

Answer: [SQL] SELECT bike_id FROM trip WHERE zip_code = 94002 GROUP BY bike_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many days had both mean humidity above 50 and mean visibility above 8?

Context: CREATE TABLE weather (mean_humidity VARCHAR, mean_visibility_miles VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM weather WHERE mean_humidity > 50 AND mean_visibility_miles > 8 [/SQL]


Question: What is the latitude, longitude, city of the station from which the shortest trip started?

Context: CREATE TABLE trip (start_station_id VARCHAR, duration VARCHAR); CREATE TABLE station (lat VARCHAR, long VARCHAR, city VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.lat, T1.long, T1.city FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id ORDER BY T2.duration LIMIT 1 [/SQL]


Question: What are the ids of stations that are located in San Francisco and have average bike availability above 10.

Context: CREATE TABLE status (id VARCHAR, station_id VARCHAR, city VARCHAR, bikes_available INTEGER); CREATE TABLE station (id VARCHAR, station_id VARCHAR, city VARCHAR, bikes_available INTEGER)

Answer: [SQL] SELECT id FROM station WHERE city = "San Francisco" INTERSECT SELECT station_id FROM status GROUP BY station_id HAVING AVG(bikes_available) > 10 [/SQL]


Question: What are the names and ids of stations that had more than 14 bikes available on average or were installed in December?

Context: CREATE TABLE station (name VARCHAR, id VARCHAR); CREATE TABLE station (name VARCHAR, id VARCHAR, installation_date VARCHAR); CREATE TABLE status (station_id VARCHAR, bikes_available INTEGER)

Answer: [SQL] SELECT T1.name, T1.id FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING AVG(T2.bikes_available) > 14 UNION SELECT name, id FROM station WHERE installation_date LIKE "12/%" [/SQL]


Question: What is the 3 most common cloud cover rates in the region of zip code 94107?

Context: CREATE TABLE weather (cloud_cover VARCHAR, zip_code VARCHAR)

Answer: [SQL] SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT(*) DESC LIMIT 3 [/SQL]


Question: What is the zip code in which the average mean sea level pressure is the lowest?

Context: CREATE TABLE weather (zip_code VARCHAR, mean_sea_level_pressure_inches INTEGER)

Answer: [SQL] SELECT zip_code FROM weather GROUP BY zip_code ORDER BY AVG(mean_sea_level_pressure_inches) LIMIT 1 [/SQL]


Question: What is the average bike availability in stations that are not located in Palo Alto?

Context: CREATE TABLE status (bikes_available INTEGER, station_id VARCHAR, id VARCHAR, city VARCHAR); CREATE TABLE station (bikes_available INTEGER, station_id VARCHAR, id VARCHAR, city VARCHAR)

Answer: [SQL] SELECT AVG(bikes_available) FROM status WHERE NOT station_id IN (SELECT id FROM station WHERE city = "Palo Alto") [/SQL]


Question: What is the average longitude of stations that never had bike availability more than 10?

Context: CREATE TABLE station (long INTEGER, id VARCHAR, station_id VARCHAR, bikes_available INTEGER); CREATE TABLE status (long INTEGER, id VARCHAR, station_id VARCHAR, bikes_available INTEGER)

Answer: [SQL] SELECT AVG(long) FROM station WHERE NOT id IN (SELECT station_id FROM status GROUP BY station_id HAVING MAX(bikes_available) > 10) [/SQL]


Question: When and in what zip code did max temperature reach 80?

Context: CREATE TABLE weather (date VARCHAR, zip_code VARCHAR, max_temperature_f VARCHAR)

Answer: [SQL] SELECT date, zip_code FROM weather WHERE max_temperature_f >= 80 [/SQL]


Question: Give me ids for all the trip that took place in a zip code area with average mean temperature above 60.

Context: CREATE TABLE trip (id VARCHAR, zip_code VARCHAR); CREATE TABLE weather (zip_code VARCHAR, mean_temperature_f INTEGER)

Answer: [SQL] SELECT T1.id FROM trip AS T1 JOIN weather AS T2 ON T1.zip_code = T2.zip_code GROUP BY T2.zip_code HAVING AVG(T2.mean_temperature_f) > 60 [/SQL]


Question: For each zip code, return how many times max wind speed reached 25?

Context: CREATE TABLE weather (zip_code VARCHAR, max_wind_Speed_mph VARCHAR)

Answer: [SQL] SELECT zip_code, COUNT(*) FROM weather WHERE max_wind_Speed_mph >= 25 GROUP BY zip_code [/SQL]


Question: On which day and in which zip code was the min dew point lower than any day in zip code 94107?

Context: CREATE TABLE weather (date VARCHAR, zip_code VARCHAR, min_dew_point_f INTEGER)

Answer: [SQL] SELECT date, zip_code FROM weather WHERE min_dew_point_f < (SELECT MIN(min_dew_point_f) FROM weather WHERE zip_code = 94107) [/SQL]


Question: For each trip, return its ending station's installation date.

Context: CREATE TABLE station (installation_date VARCHAR, id VARCHAR); CREATE TABLE trip (id VARCHAR, end_station_id VARCHAR)

Answer: [SQL] SELECT T1.id, T2.installation_date FROM trip AS T1 JOIN station AS T2 ON T1.end_station_id = T2.id [/SQL]


Question: Which trip started from the station with the largest dock count? Give me the trip id.

Context: CREATE TABLE trip (id VARCHAR, start_station_id VARCHAR); CREATE TABLE station (id VARCHAR, dock_count VARCHAR)

Answer: [SQL] SELECT T1.id FROM trip AS T1 JOIN station AS T2 ON T1.start_station_id = T2.id ORDER BY T2.dock_count DESC LIMIT 1 [/SQL]


Question: Count the number of trips that did not end in San Francisco city.

Context: CREATE TABLE trip (end_station_id VARCHAR); CREATE TABLE station (id VARCHAR, city VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM trip AS T1 JOIN station AS T2 ON T1.end_station_id = T2.id WHERE T2.city <> "San Francisco" [/SQL]


Question: In zip code 94107, on which day neither Fog nor Rain was not observed?

Context: CREATE TABLE weather (date VARCHAR, EVENTS VARCHAR, zip_code VARCHAR)

Answer: [SQL] SELECT date FROM weather WHERE zip_code = 94107 AND EVENTS <> "Fog" AND EVENTS <> "Rain" [/SQL]


Question: What are the ids of stations that have latitude above 37.4 and never had bike availability below 7?

Context: CREATE TABLE status (id VARCHAR, station_id VARCHAR, lat INTEGER, bikes_available INTEGER); CREATE TABLE station (id VARCHAR, station_id VARCHAR, lat INTEGER, bikes_available INTEGER)

Answer: [SQL] SELECT id FROM station WHERE lat > 37.4 EXCEPT SELECT station_id FROM status GROUP BY station_id HAVING MIN(bikes_available) < 7 [/SQL]


Question: What are names of stations that have average bike availability above 10 and are not located in San Jose city?

Context: CREATE TABLE station (name VARCHAR, id VARCHAR); CREATE TABLE status (station_id VARCHAR); CREATE TABLE station (name VARCHAR, city VARCHAR, bikes_available INTEGER)

Answer: [SQL] SELECT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING AVG(bikes_available) > 10 EXCEPT SELECT name FROM station WHERE city = "San Jose" [/SQL]


Question: What are the name, latitude, and city of the station with the lowest latitude?

Context: CREATE TABLE station (name VARCHAR, lat VARCHAR, city VARCHAR)

Answer: [SQL] SELECT name, lat, city FROM station ORDER BY lat LIMIT 1 [/SQL]


Question: What are the date, mean temperature and mean humidity for the top 3 days with the largest max gust speeds?

Context: CREATE TABLE weather (date VARCHAR, mean_temperature_f VARCHAR, mean_humidity VARCHAR, max_gust_speed_mph VARCHAR)

Answer: [SQL] SELECT date, mean_temperature_f, mean_humidity FROM weather ORDER BY max_gust_speed_mph DESC LIMIT 3 [/SQL]


Question: List the name and the number of stations for all the cities that have at least 15 stations.

Context: CREATE TABLE station (city VARCHAR)

Answer: [SQL] SELECT city, COUNT(*) FROM station GROUP BY city HAVING COUNT(*) >= 15 [/SQL]


Question: Find the ids and names of stations from which at least 200 trips started.

Context: CREATE TABLE trip (start_station_id VARCHAR, start_station_name VARCHAR)

Answer: [SQL] SELECT start_station_id, start_station_name FROM trip GROUP BY start_station_name HAVING COUNT(*) >= 200 [/SQL]


Question: Find the zip code in which the average mean visibility is lower than 10.

Context: CREATE TABLE weather (zip_code VARCHAR, mean_visibility_miles INTEGER)

Answer: [SQL] SELECT zip_code FROM weather GROUP BY zip_code HAVING AVG(mean_visibility_miles) < 10 [/SQL]


Question: List all the cities in a decreasing order of each city's stations' highest latitude.

Context: CREATE TABLE station (city VARCHAR, lat INTEGER)

Answer: [SQL] SELECT city FROM station GROUP BY city ORDER BY MAX(lat) DESC [/SQL]


Question: What are the dates that had the top 5 cloud cover rates? Also tell me the cloud cover rate.

Context: CREATE TABLE weather (date VARCHAR, cloud_cover VARCHAR)

Answer: [SQL] SELECT date, cloud_cover FROM weather ORDER BY cloud_cover DESC LIMIT 5 [/SQL]


Question: What are the ids and durations of the trips with the top 3 durations?

Context: CREATE TABLE trip (id VARCHAR, duration VARCHAR)

Answer: [SQL] SELECT id, duration FROM trip ORDER BY duration DESC LIMIT 3 [/SQL]


Question: For each station, return its longitude and the average duration of trips that started from the station.

Context: CREATE TABLE station (name VARCHAR, long VARCHAR, id VARCHAR); CREATE TABLE trip (duration INTEGER, start_station_id VARCHAR)

Answer: [SQL] SELECT T1.name, T1.long, AVG(T2.duration) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id GROUP BY T2.start_station_id [/SQL]


Question: For each station, find its latitude and the minimum duration of trips that ended at the station.

Context: CREATE TABLE trip (duration INTEGER, end_station_id VARCHAR); CREATE TABLE station (name VARCHAR, lat VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.name, T1.lat, MIN(T2.duration) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.end_station_id GROUP BY T2.end_station_id [/SQL]


Question: List all the distinct stations from which a trip of duration below 100 started.

Context: CREATE TABLE trip (start_station_name VARCHAR, duration INTEGER)

Answer: [SQL] SELECT DISTINCT start_station_name FROM trip WHERE duration < 100 [/SQL]


Question: Find all the zip codes in which the max dew point have never reached 70.

Context: CREATE TABLE weather (zip_code VARCHAR, max_dew_point_f VARCHAR)

Answer: [SQL] SELECT DISTINCT zip_code FROM weather EXCEPT SELECT DISTINCT zip_code FROM weather WHERE max_dew_point_f >= 70 [/SQL]


Question: Find the id for the trips that lasted at least as long as the average duration of trips in zip code 94103.

Context: CREATE TABLE trip (id VARCHAR, duration INTEGER, zip_code VARCHAR)

Answer: [SQL] SELECT id FROM trip WHERE duration >= (SELECT AVG(duration) FROM trip WHERE zip_code = 94103) [/SQL]


Question: What are the dates in which the mean sea level pressure was between 30.3 and 31?

Context: CREATE TABLE weather (date VARCHAR, mean_sea_level_pressure_inches INTEGER)

Answer: [SQL] SELECT date FROM weather WHERE mean_sea_level_pressure_inches BETWEEN 30.3 AND 31 [/SQL]


Question: Find the day in which the difference between the max temperature and min temperature was the smallest. Also report the difference.

Context: CREATE TABLE weather (date VARCHAR, max_temperature_f VARCHAR, min_temperature_f VARCHAR)

Answer: [SQL] SELECT date, max_temperature_f - min_temperature_f FROM weather ORDER BY max_temperature_f - min_temperature_f LIMIT 1 [/SQL]


Question: What are the id and name of the stations that have ever had more than 12 bikes available?

Context: CREATE TABLE station (id VARCHAR, name VARCHAR); CREATE TABLE status (station_id VARCHAR, bikes_available INTEGER)

Answer: [SQL] SELECT DISTINCT T1.id, T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available > 12 [/SQL]


Question: Give me the zip code where the average mean humidity is below 70 and at least 100 trips took place.

Context: CREATE TABLE weather (zip_code VARCHAR, mean_humidity INTEGER); CREATE TABLE trip (zip_code VARCHAR, mean_humidity INTEGER)

Answer: [SQL] SELECT zip_code FROM weather GROUP BY zip_code HAVING AVG(mean_humidity) < 70 INTERSECT SELECT zip_code FROM trip GROUP BY zip_code HAVING COUNT(*) >= 100 [/SQL]


Question: What are the names of stations that are located in Palo Alto city but have never been the ending point of trips more than 100 times?

Context: CREATE TABLE trip (name VARCHAR, end_station_name VARCHAR, city VARCHAR); CREATE TABLE station (name VARCHAR, end_station_name VARCHAR, city VARCHAR)

Answer: [SQL] SELECT name FROM station WHERE city = "Palo Alto" EXCEPT SELECT end_station_name FROM trip GROUP BY end_station_name HAVING COUNT(*) > 100 [/SQL]


Question: How many trips started from Mountain View city and ended at Palo Alto city?

Context: CREATE TABLE station (city VARCHAR, id VARCHAR); CREATE TABLE trip (end_station_id VARCHAR, id VARCHAR); CREATE TABLE station (id VARCHAR, city VARCHAR); CREATE TABLE trip (start_station_id VARCHAR, id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM station AS T1 JOIN trip AS T2 JOIN station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "Mountain View" AND T3.city = "Palo Alto" [/SQL]


Question: What is the average latitude and longitude of the starting points of all trips?

Context: CREATE TABLE trip (start_station_id VARCHAR); CREATE TABLE station (lat INTEGER, long INTEGER, id VARCHAR)

Answer: [SQL] SELECT AVG(T1.lat), AVG(T1.long) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id [/SQL]


Question: How many books are there?

Context: CREATE TABLE book (Id VARCHAR)

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


Question: List the writers of the books in ascending alphabetical order.

Context: CREATE TABLE book (Writer VARCHAR)

Answer: [SQL] SELECT Writer FROM book ORDER BY Writer [/SQL]


Question: List the titles of the books in ascending order of issues.

Context: CREATE TABLE book (Title VARCHAR, Issues VARCHAR)

Answer: [SQL] SELECT Title FROM book ORDER BY Issues [/SQL]


Question: What are the titles of the books whose writer is not "Elaine Lee"?

Context: CREATE TABLE book (Title VARCHAR, Writer VARCHAR)

Answer: [SQL] SELECT Title FROM book WHERE Writer <> "Elaine Lee" [/SQL]


Question: What are the title and issues of the books?

Answer: [SQL] SELECT Title, Issues FROM book [/SQL]


Question: What are the dates of publications in descending order of price?

Context: CREATE TABLE publication (Publication_Date VARCHAR, Price VARCHAR)

Answer: [SQL] SELECT Publication_Date FROM publication ORDER BY Price DESC [/SQL]


Question: What are the distinct publishers of publications with price higher than 5000000?

Context: CREATE TABLE publication (Publisher VARCHAR, Price INTEGER)

Answer: [SQL] SELECT DISTINCT Publisher FROM publication WHERE Price > 5000000 [/SQL]


Question: List the publisher of the publication with the highest price.

Context: CREATE TABLE publication (Publisher VARCHAR, Price VARCHAR)

Answer: [SQL] SELECT Publisher FROM publication ORDER BY Price DESC LIMIT 1 [/SQL]


Question: List the publication dates of publications with 3 lowest prices.

Answer: [SQL] SELECT Publication_Date FROM publication ORDER BY Price LIMIT 3 [/SQL]


Question: Show the title and publication dates of books.

Context: CREATE TABLE book (Title VARCHAR, Book_ID VARCHAR); CREATE TABLE publication (Publication_Date VARCHAR, Book_ID VARCHAR)

Answer: [SQL] SELECT T1.Title, T2.Publication_Date FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID [/SQL]


Question: Show writers who have published a book with price more than 4000000.

Context: CREATE TABLE publication (Book_ID VARCHAR, Price INTEGER); CREATE TABLE book (Writer VARCHAR, Book_ID VARCHAR)

Answer: [SQL] SELECT T1.Writer FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID WHERE T2.Price > 4000000 [/SQL]


Question: Show the titles of books in descending order of publication price.

Context: CREATE TABLE publication (Book_ID VARCHAR, Price VARCHAR); CREATE TABLE book (Title VARCHAR, Book_ID VARCHAR)

Answer: [SQL] SELECT T1.Title FROM book AS T1 JOIN publication AS T2 ON T1.Book_ID = T2.Book_ID ORDER BY T2.Price DESC [/SQL]


Question: Show publishers that have more than one publication.

Context: CREATE TABLE publication (Publisher VARCHAR)

Answer: [SQL] SELECT Publisher FROM publication GROUP BY Publisher HAVING COUNT(*) > 1 [/SQL]


Question: Show different publishers together with the number of publications they have.

Answer: [SQL] SELECT Publisher, COUNT(*) FROM publication GROUP BY Publisher [/SQL]


Question: Please show the most common publication date.

Context: CREATE TABLE publication (Publication_Date VARCHAR)

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


Question: List the writers who have written more than one book.

Context: CREATE TABLE book (Writer VARCHAR)

Answer: [SQL] SELECT Writer FROM book GROUP BY Writer HAVING COUNT(*) > 1 [/SQL]


Question: List the titles of books that are not published.

Context: CREATE TABLE book (Title VARCHAR, Book_ID VARCHAR); CREATE TABLE publication (Title VARCHAR, Book_ID VARCHAR)

Answer: [SQL] SELECT Title FROM book WHERE NOT Book_ID IN (SELECT Book_ID FROM publication) [/SQL]


Question: Show the publishers that have publications with price higher than 10000000 and publications with price lower than 5000000.

Answer: [SQL] SELECT Publisher FROM publication WHERE Price > 10000000 INTERSECT SELECT Publisher FROM publication WHERE Price < 5000000 [/SQL]


Question: What is the number of distinct publication dates?

Answer: [SQL] SELECT COUNT(DISTINCT Publication_Date) FROM publication [/SQL]


Question: Show the prices of publications whose publisher is either "Person" or "Wiley"

Context: CREATE TABLE publication (Price VARCHAR, Publisher VARCHAR)

Answer: [SQL] SELECT Price FROM publication WHERE Publisher = "Person" OR Publisher = "Wiley" [/SQL]


Question: How many actors are there?

Context: CREATE TABLE actor (Id VARCHAR)

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


Question: List the name of actors in ascending alphabetical order.

Context: CREATE TABLE actor (Name VARCHAR)

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


Question: What are the characters and duration of actors?

Context: CREATE TABLE actor (Character VARCHAR, Duration VARCHAR)

Answer: [SQL] SELECT Character, Duration FROM actor [/SQL]


Question: List the name of actors whose age is not 20.

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

Answer: [SQL] SELECT Name FROM actor WHERE Age <> 20 [/SQL]


Question: What are the characters of actors in descending order of age?

Context: CREATE TABLE actor (Character VARCHAR, age VARCHAR)

Answer: [SQL] SELECT Character FROM actor ORDER BY age DESC [/SQL]


Question: What is the duration of the oldest actor?

Context: CREATE TABLE actor (Duration VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Duration FROM actor ORDER BY Age DESC LIMIT 1 [/SQL]


Question: What are the names of musicals with nominee "Bob Fosse"?

Context: CREATE TABLE musical (Name VARCHAR, Nominee VARCHAR)

Answer: [SQL] SELECT Name FROM musical WHERE Nominee = "Bob Fosse" [/SQL]


Question: What are the distinct nominees of the musicals with the award that is not "Tony Award"?

Context: CREATE TABLE musical (Nominee VARCHAR, Award VARCHAR)

Answer: [SQL] SELECT DISTINCT Nominee FROM musical WHERE Award <> "Tony Award" [/SQL]


Question: Show names of actors and names of musicals they are in.

Context: CREATE TABLE actor (Name VARCHAR, Musical_ID VARCHAR); CREATE TABLE musical (Name VARCHAR, Musical_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID [/SQL]


Question: Show names of actors that have appeared in musical with name "The Phantom of the Opera".

Context: CREATE TABLE actor (Name VARCHAR, Musical_ID VARCHAR); CREATE TABLE musical (Musical_ID VARCHAR, Name VARCHAR)

Answer: [SQL] SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID WHERE T2.Name = "The Phantom of the Opera" [/SQL]


Question: Show names of actors in descending order of the year their musical is awarded.

Context: CREATE TABLE musical (Musical_ID VARCHAR, Year VARCHAR); CREATE TABLE actor (Name VARCHAR, Musical_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID ORDER BY T2.Year DESC [/SQL]


Question: Show names of musicals and the number of actors who have appeared in the musicals.

Context: CREATE TABLE actor (Musical_ID VARCHAR); CREATE TABLE musical (Name VARCHAR, Musical_ID VARCHAR)

Answer: [SQL] SELECT T2.Name, COUNT(*) FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID [/SQL]


Question: Show names of musicals which have at least three actors.

Answer: [SQL] SELECT T2.Name FROM actor AS T1 JOIN musical AS T2 ON T1.Musical_ID = T2.Musical_ID GROUP BY T1.Musical_ID HAVING COUNT(*) >= 3 [/SQL]


Question: Show different nominees and the number of musicals they have been nominated.

Context: CREATE TABLE musical (Nominee VARCHAR)

Answer: [SQL] SELECT Nominee, COUNT(*) FROM musical GROUP BY Nominee [/SQL]


Question: Please show the nominee who has been nominated the greatest number of times.

Context: CREATE TABLE musical (Nominee VARCHAR)

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


Question: List the most common result of the musicals.

Context: CREATE TABLE musical (RESULT VARCHAR)

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


Question: List the nominees that have been nominated more than two musicals.

Context: CREATE TABLE musical (Nominee VARCHAR)

Answer: [SQL] SELECT Nominee FROM musical GROUP BY Nominee HAVING COUNT(*) > 2 [/SQL]


Question: List the name of musicals that do not have actors.

Answer: [SQL] SELECT Name FROM musical WHERE NOT Musical_ID IN (SELECT Musical_ID FROM actor) [/SQL]


Question: Show the nominees that have nominated musicals for both "Tony Award" and "Drama Desk Award".

Answer: [SQL] SELECT Nominee FROM musical WHERE Award = "Tony Award" INTERSECT SELECT Nominee FROM musical WHERE Award = "Drama Desk Award" [/SQL]


Question: Show the musical nominee with award "Bob Fosse" or "Cleavant Derricks".

Answer: [SQL] SELECT Nominee FROM musical WHERE Award = "Tony Award" OR Award = "Cleavant Derricks" [/SQL]


Question: Find the emails of the user named "Mary".

Context: CREATE TABLE user_profiles (email VARCHAR, name VARCHAR)

Answer: [SQL] SELECT email FROM user_profiles WHERE name = 'Mary' [/SQL]


Question: What is the partition id of the user named "Iron Man".

Context: CREATE TABLE user_profiles (partitionid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT partitionid FROM user_profiles WHERE name = 'Iron Man' [/SQL]


Question: How many users are there?

Context: CREATE TABLE user_profiles (Id VARCHAR)

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


Question: How many followers does each user have?

Context: CREATE TABLE follows (Id VARCHAR)

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


Question: Find the number of followers for each user.

Context: CREATE TABLE follows (f1 VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM follows GROUP BY f1 [/SQL]


Question: Find the number of tweets in record.

Context: CREATE TABLE tweets (Id VARCHAR)

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


Question: Find the number of users who posted some tweets.

Context: CREATE TABLE tweets (UID VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT UID) FROM tweets [/SQL]


Question: Find the name and email of the user whose name contains the word ‘Swift’.

Context: CREATE TABLE user_profiles (name VARCHAR, email VARCHAR)

Answer: [SQL] SELECT name, email FROM user_profiles WHERE name LIKE '%Swift%' [/SQL]


Question: Find the names of users whose emails contain ‘superstar’ or ‘edu’.

Answer: [SQL] SELECT name FROM user_profiles WHERE email LIKE '%superstar%' OR email LIKE '%edu%' [/SQL]


Question: Return the text of tweets about the topic 'intern'.

Context: CREATE TABLE tweets (text VARCHAR)

Answer: [SQL] SELECT text FROM tweets WHERE text LIKE '%intern%' [/SQL]


Question: Find the name and email of the users who have more than 1000 followers.

Context: CREATE TABLE user_profiles (name VARCHAR, email VARCHAR, followers INTEGER)

Answer: [SQL] SELECT name, email FROM user_profiles WHERE followers > 1000 [/SQL]


Question: Find the names of the users whose number of followers is greater than that of the user named "Tyler Swift".

Context: CREATE TABLE follows (f1 VARCHAR); CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR)

Answer: [SQL] SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING COUNT(*) > (SELECT COUNT(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 WHERE T1.name = 'Tyler Swift') [/SQL]


Question: Find the name and email for the users who have more than one follower.

Context: CREATE TABLE follows (f1 VARCHAR); CREATE TABLE user_profiles (name VARCHAR, email VARCHAR, uid VARCHAR)

Answer: [SQL] SELECT T1.name, T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING COUNT(*) > 1 [/SQL]


Question: Find the names of users who have more than one tweet.

Context: CREATE TABLE tweets (uid VARCHAR); CREATE TABLE user_profiles (name VARCHAR, uid VARCHAR)

Answer: [SQL] SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) > 1 [/SQL]


Question: Find the id of users who are followed by Mary and Susan.

Context: CREATE TABLE follows (f1 VARCHAR, f2 VARCHAR); CREATE TABLE user_profiles (uid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Mary" INTERSECT SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Susan" [/SQL]


Question: Find the id of users who are followed by Mary or Susan.

Answer: [SQL] SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Mary" OR T1.name = "Susan" [/SQL]


Question: Find the name of the user who has the largest number of followers.

Context: CREATE TABLE user_profiles (name VARCHAR, followers VARCHAR)

Answer: [SQL] SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1 [/SQL]


Question: Find the name and email of the user followed by the least number of people.

Context: CREATE TABLE user_profiles (name VARCHAR, email VARCHAR, followers VARCHAR)

Answer: [SQL] SELECT name, email FROM user_profiles ORDER BY followers LIMIT 1 [/SQL]


Question: List the name and number of followers for each user, and sort the results by the number of followers in descending order.

Answer: [SQL] SELECT name, followers FROM user_profiles ORDER BY followers DESC [/SQL]


Question: List the names of 5 users followed by the largest number of other users.

Answer: [SQL] SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 5 [/SQL]


Question: List the text of all tweets in the order of date.

Context: CREATE TABLE tweets (text VARCHAR, createdate VARCHAR)

Answer: [SQL] SELECT text FROM tweets ORDER BY createdate [/SQL]


Question: Find the name of each user and number of tweets tweeted by each of them.

Answer: [SQL] SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid [/SQL]


Question: Find the name and partition id for users who tweeted less than twice.

Context: CREATE TABLE user_profiles (name VARCHAR, partitionid VARCHAR, uid VARCHAR); CREATE TABLE tweets (uid VARCHAR)

Answer: [SQL] SELECT T1.name, T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) < 2 [/SQL]


Question: Find the name of the user who tweeted more than once, and number of tweets tweeted by them.

Answer: [SQL] SELECT T1.name, COUNT(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid = T2.uid GROUP BY T2.uid HAVING COUNT(*) > 1 [/SQL]


Question: Find the average number of followers for the users who do not have any tweet.

Context: CREATE TABLE user_profiles (followers INTEGER, UID VARCHAR); CREATE TABLE tweets (followers INTEGER, UID VARCHAR)

Answer: [SQL] SELECT AVG(followers) FROM user_profiles WHERE NOT UID IN (SELECT UID FROM tweets) [/SQL]


Question: Find the average number of followers for the users who had some tweets.

Answer: [SQL] SELECT AVG(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets) [/SQL]


Question: Find the maximum and total number of followers of all users.

Context: CREATE TABLE user_profiles (followers INTEGER)

Answer: [SQL] SELECT MAX(followers), SUM(followers) FROM user_profiles [/SQL]


Question: Find the names of all the catalog entries.

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR)

Answer: [SQL] SELECT DISTINCT (catalog_entry_name) FROM catalog_contents [/SQL]


Question: Find the list of attribute data types possessed by more than 3 attribute definitions.

Context: CREATE TABLE Attribute_Definitions (attribute_data_type VARCHAR)

Answer: [SQL] SELECT attribute_data_type FROM Attribute_Definitions GROUP BY attribute_data_type HAVING COUNT(*) > 3 [/SQL]


Question: What is the attribute data type of the attribute with name "Green"?

Context: CREATE TABLE Attribute_Definitions (attribute_data_type VARCHAR, attribute_name VARCHAR)

Answer: [SQL] SELECT attribute_data_type FROM Attribute_Definitions WHERE attribute_name = "Green" [/SQL]


Question: Find the name and level of catalog structure with level between 5 and 10.

Context: CREATE TABLE Catalog_Structure (catalog_level_name VARCHAR, catalog_level_number INTEGER)

Answer: [SQL] SELECT catalog_level_name, catalog_level_number FROM Catalog_Structure WHERE catalog_level_number BETWEEN 5 AND 10 [/SQL]


Question: Find all the catalog publishers whose name contains "Murray"

Context: CREATE TABLE catalogs (catalog_publisher VARCHAR)

Answer: [SQL] SELECT DISTINCT (catalog_publisher) FROM catalogs WHERE catalog_publisher LIKE "%Murray%" [/SQL]


Question: Which catalog publisher has published the most catalogs?

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


Question: Find the names and publication dates of all catalogs that have catalog level number greater than 5.

Context: CREATE TABLE catalogs (catalog_name VARCHAR, date_of_publication VARCHAR, catalog_id VARCHAR); CREATE TABLE catalog_structure (catalog_id VARCHAR)

Answer: [SQL] SELECT t1.catalog_name, t1.date_of_publication FROM catalogs AS t1 JOIN catalog_structure AS t2 ON t1.catalog_id = t2.catalog_id WHERE catalog_level_number > 5 [/SQL]


Question: What are the entry names of catalog with the attribute possessed by most entries.

Context: CREATE TABLE Catalog_Contents_Additional_Attributes (catalog_entry_id VARCHAR, attribute_value VARCHAR); CREATE TABLE Catalog_Contents (catalog_entry_name VARCHAR, catalog_entry_id VARCHAR); CREATE TABLE Catalog_Contents_Additional_Attributes (attribute_value VARCHAR)

Answer: [SQL] SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.attribute_value = (SELECT attribute_value FROM Catalog_Contents_Additional_Attributes GROUP BY attribute_value ORDER BY COUNT(*) DESC LIMIT 1) [/SQL]


Question: What is the entry name of the most expensive catalog (in USD)?

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, price_in_dollars VARCHAR)

Answer: [SQL] SELECT catalog_entry_name FROM catalog_contents ORDER BY price_in_dollars DESC LIMIT 1 [/SQL]


Question: What is the level name of the cheapest catalog (in USD)?

Context: CREATE TABLE catalog_structure (catalog_level_name VARCHAR, catalog_level_number VARCHAR); CREATE TABLE catalog_contents (catalog_level_number VARCHAR, price_in_dollars VARCHAR)

Answer: [SQL] SELECT t2.catalog_level_name FROM catalog_contents AS t1 JOIN catalog_structure AS t2 ON t1.catalog_level_number = t2.catalog_level_number ORDER BY t1.price_in_dollars LIMIT 1 [/SQL]


Question: What are the average and minimum price (in Euro) of all products?

Context: CREATE TABLE catalog_contents (price_in_euros INTEGER)

Answer: [SQL] SELECT AVG(price_in_euros), MIN(price_in_euros) FROM catalog_contents [/SQL]


Question: What is the product with the highest height? Give me the catalog entry name.

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, height VARCHAR)

Answer: [SQL] SELECT catalog_entry_name FROM catalog_contents ORDER BY height DESC LIMIT 1 [/SQL]


Question: Find the name of the product that has the smallest capacity.

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, capacity VARCHAR)

Answer: [SQL] SELECT catalog_entry_name FROM catalog_contents ORDER BY capacity LIMIT 1 [/SQL]


Question: Find the names of all the products whose stock number starts with "2".

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, product_stock_number VARCHAR)

Answer: [SQL] SELECT catalog_entry_name FROM catalog_contents WHERE product_stock_number LIKE "2%" [/SQL]


Question: Find the names of catalog entries with level number 8.

Context: CREATE TABLE Catalog_Contents_Additional_Attributes (catalog_entry_id VARCHAR, catalog_level_number VARCHAR); CREATE TABLE Catalog_Contents (catalog_entry_name VARCHAR, catalog_entry_id VARCHAR)

Answer: [SQL] SELECT t1.catalog_entry_name FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.catalog_level_number = "8" [/SQL]


Question: Find the names of the products with length smaller than 3 or height greater than 5.

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, LENGTH VARCHAR, width VARCHAR)

Answer: [SQL] SELECT catalog_entry_name FROM catalog_contents WHERE LENGTH < 3 OR width > 5 [/SQL]


Question: Find the name and attribute ID of the attribute definitions with attribute value 0.

Context: CREATE TABLE Catalog_Contents_Additional_Attributes (attribute_id VARCHAR, attribute_value VARCHAR); CREATE TABLE Attribute_Definitions (attribute_name VARCHAR, attribute_id VARCHAR)

Answer: [SQL] SELECT t1.attribute_name, t1.attribute_id FROM Attribute_Definitions AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.attribute_id = t2.attribute_id WHERE t2.attribute_value = 0 [/SQL]


Question: Find the name and capacity of products with price greater than 700 (in USD).

Context: CREATE TABLE Catalog_Contents (catalog_entry_name VARCHAR, capacity VARCHAR, price_in_dollars INTEGER)

Answer: [SQL] SELECT catalog_entry_name, capacity FROM Catalog_Contents WHERE price_in_dollars > 700 [/SQL]


Question: Find the dates on which more than one revisions were made.

Context: CREATE TABLE Catalogs (date_of_latest_revision VARCHAR)

Answer: [SQL] SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING COUNT(*) > 1 [/SQL]


Question: How many products are there in the records?

Context: CREATE TABLE catalog_contents (Id VARCHAR)

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


Question: Name all the products with next entry ID greater than 8.

Context: CREATE TABLE catalog_contents (catalog_entry_name VARCHAR, next_entry_id INTEGER)

Answer: [SQL] SELECT catalog_entry_name FROM catalog_contents WHERE next_entry_id > 8 [/SQL]


Question: How many aircrafts do we have?

Context: CREATE TABLE Aircraft (Id VARCHAR)

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


Question: Show name and distance for all aircrafts.

Context: CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR)

Answer: [SQL] SELECT name, distance FROM Aircraft [/SQL]


Question: Show ids for all aircrafts with more than 1000 distance.

Context: CREATE TABLE Aircraft (aid VARCHAR, distance INTEGER)

Answer: [SQL] SELECT aid FROM Aircraft WHERE distance > 1000 [/SQL]


Question: How many aircrafts have distance between 1000 and 5000?

Context: CREATE TABLE Aircraft (distance INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000 [/SQL]


Question: What is the name and distance for aircraft with id 12?

Context: CREATE TABLE Aircraft (name VARCHAR, distance VARCHAR, aid VARCHAR)

Answer: [SQL] SELECT name, distance FROM Aircraft WHERE aid = 12 [/SQL]


Question: What is the minimum, average, and maximum distance of all aircrafts.

Answer: [SQL] SELECT MIN(distance), AVG(distance), MAX(distance) FROM Aircraft [/SQL]


Question: Show the id and name of the aircraft with the maximum distance.

Context: CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR, distance VARCHAR)

Answer: [SQL] SELECT aid, name FROM Aircraft ORDER BY distance DESC LIMIT 1 [/SQL]


Question: Show the name of aircrafts with top three lowest distances.

Answer: [SQL] SELECT name FROM Aircraft ORDER BY distance LIMIT 3 [/SQL]


Question: Show names for all aircrafts with distances more than the average.

Context: CREATE TABLE Aircraft (name VARCHAR, distance INTEGER)

Answer: [SQL] SELECT name FROM Aircraft WHERE distance > (SELECT AVG(distance) FROM Aircraft) [/SQL]


Question: How many employees do we have?

Context: CREATE TABLE Employee (Id VARCHAR)

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


Question: Show name and salary for all employees sorted by salary.

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

Answer: [SQL] SELECT name, salary FROM Employee ORDER BY salary [/SQL]


Question: Show ids for all employees with at least 100000 salary.

Context: CREATE TABLE Employee (eid VARCHAR, salary INTEGER)

Answer: [SQL] SELECT eid FROM Employee WHERE salary > 100000 [/SQL]


Question: How many employees have salary between 100000 and 200000?

Context: CREATE TABLE Employee (salary INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000 [/SQL]


Question: What is the name and salary for employee with id 242518965?

Context: CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR)

Answer: [SQL] SELECT name, salary FROM Employee WHERE eid = 242518965 [/SQL]


Question: What is average and maximum salary of all employees.

Context: CREATE TABLE Employee (salary INTEGER)

Answer: [SQL] SELECT AVG(salary), MAX(salary) FROM Employee [/SQL]


Question: Show the id and name of the employee with maximum salary.

Context: CREATE TABLE Employee (eid VARCHAR, name VARCHAR, salary VARCHAR)

Answer: [SQL] SELECT eid, name FROM Employee ORDER BY salary DESC LIMIT 1 [/SQL]


Question: Show the name of employees with three lowest salaries.

Answer: [SQL] SELECT name FROM Employee ORDER BY salary LIMIT 3 [/SQL]


Question: Show names for all employees with salary more than the average.

Context: CREATE TABLE Employee (name VARCHAR, salary INTEGER)

Answer: [SQL] SELECT name FROM Employee WHERE salary > (SELECT AVG(salary) FROM Employee) [/SQL]


Question: Show the id and salary of Mark Young.

Context: CREATE TABLE Employee (eid VARCHAR, salary VARCHAR, name VARCHAR)

Answer: [SQL] SELECT eid, salary FROM Employee WHERE name = 'Mark Young' [/SQL]


Question: How many flights do we have?

Context: CREATE TABLE Flight (Id VARCHAR)

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


Question: Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.

Context: CREATE TABLE Flight (flno VARCHAR, origin VARCHAR, destination VARCHAR)

Answer: [SQL] SELECT flno, origin, destination FROM Flight ORDER BY origin [/SQL]


Question: Show all flight number from Los Angeles.

Context: CREATE TABLE Flight (flno VARCHAR, origin VARCHAR)

Answer: [SQL] SELECT flno FROM Flight WHERE origin = "Los Angeles" [/SQL]


Question: Show origins of all flights with destination Honolulu.

Context: CREATE TABLE Flight (origin VARCHAR, destination VARCHAR)

Answer: [SQL] SELECT origin FROM Flight WHERE destination = "Honolulu" [/SQL]


Question: Show me the departure date and arrival date for all flights from Los Angeles to Honolulu.

Context: CREATE TABLE Flight (departure_date VARCHAR, arrival_date VARCHAR, origin VARCHAR, destination VARCHAR)

Answer: [SQL] SELECT departure_date, arrival_date FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu" [/SQL]


Question: Show flight number for all flights with more than 2000 distance.

Context: CREATE TABLE Flight (flno VARCHAR, distance INTEGER)

Answer: [SQL] SELECT flno FROM Flight WHERE distance > 2000 [/SQL]


Question: What is the average price for flights from Los Angeles to Honolulu.

Context: CREATE TABLE Flight (price INTEGER, origin VARCHAR, destination VARCHAR)

Answer: [SQL] SELECT AVG(price) FROM Flight WHERE origin = "Los Angeles" AND destination = "Honolulu" [/SQL]


Question: Show origin and destination for flights with price higher than 300.

Context: CREATE TABLE Flight (origin VARCHAR, destination VARCHAR, price INTEGER)

Answer: [SQL] SELECT origin, destination FROM Flight WHERE price > 300 [/SQL]


Question: Show the flight number and distance of the flight with maximum price.

Context: CREATE TABLE Flight (flno VARCHAR, distance VARCHAR, price VARCHAR)

Answer: [SQL] SELECT flno, distance FROM Flight ORDER BY price DESC LIMIT 1 [/SQL]


Question: Show the flight number of flights with three lowest distances.

Context: CREATE TABLE Flight (flno VARCHAR, distance VARCHAR)

Answer: [SQL] SELECT flno FROM Flight ORDER BY distance LIMIT 3 [/SQL]


Question: What is the average distance and average price for flights from Los Angeles.

Context: CREATE TABLE Flight (distance INTEGER, price INTEGER, origin VARCHAR)

Answer: [SQL] SELECT AVG(distance), AVG(price) FROM Flight WHERE origin = "Los Angeles" [/SQL]


Question: Show all origins and the number of flights from each origin.

Context: CREATE TABLE Flight (origin VARCHAR)

Answer: [SQL] SELECT origin, COUNT(*) FROM Flight GROUP BY origin [/SQL]


Question: Show all destinations and the number of flights to each destination.

Context: CREATE TABLE Flight (destination VARCHAR)

Answer: [SQL] SELECT destination, COUNT(*) FROM Flight GROUP BY destination [/SQL]


Question: Which origin has most number of flights?

Context: CREATE TABLE Flight (origin VARCHAR)

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


Question: Which destination has least number of flights?

Answer: [SQL] SELECT destination FROM Flight GROUP BY destination ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: What is the aircraft name for the flight with number 99

Context: CREATE TABLE Flight (aid VARCHAR, flno VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR)

Answer: [SQL] SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T1.flno = 99 [/SQL]


Question: Show all flight numbers with aircraft Airbus A340-300.

Context: CREATE TABLE Flight (flno VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300" [/SQL]


Question: Show aircraft names and number of flights for each aircraft.

Context: CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Flight (aid VARCHAR)

Answer: [SQL] SELECT T2.name, COUNT(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid [/SQL]


Question: Show names for all aircraft with at least two flights.

Answer: [SQL] SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING COUNT(*) >= 2 [/SQL]


Question: How many employees have certificate.

Context: CREATE TABLE Certificate (eid VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT eid) FROM Certificate [/SQL]


Question: Show ids for all employees who don't have a certificate.

Context: CREATE TABLE Employee (eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR)

Answer: [SQL] SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate [/SQL]


Question: Show names for all aircrafts of which John Williams has certificates.

Context: CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR); CREATE TABLE Employee (eid VARCHAR, name VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR)

Answer: [SQL] SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T1.name = "John Williams" [/SQL]


Question: Show names for all employees who have certificate of Boeing 737-800.

Context: CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" [/SQL]


Question: Show names for all employees who have certificates on both Boeing 737-800 and Airbus A340-300.

Answer: [SQL] SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" INTERSECT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Airbus A340-300" [/SQL]


Question: Show names for all employees who do not have certificate of Boeing 737-800.

Context: CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Employee (name VARCHAR); CREATE TABLE Aircraft (aid VARCHAR, name VARCHAR)

Answer: [SQL] SELECT name FROM Employee EXCEPT SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.name = "Boeing 737-800" [/SQL]


Question: Show the name of aircraft which fewest people have its certificate.

Context: CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR)

Answer: [SQL] SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the name and distance of the aircrafts with more than 5000 distance and which at least 5 people have its certificate.

Context: CREATE TABLE Certificate (aid VARCHAR); CREATE TABLE Aircraft (name VARCHAR, aid VARCHAR, distance INTEGER)

Answer: [SQL] SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid WHERE T2.distance > 5000 GROUP BY T1.aid ORDER BY COUNT(*) >= 5 [/SQL]


Question: what is the salary and name of the employee who has the most number of aircraft certificates?

Context: CREATE TABLE Certificate (eid VARCHAR); CREATE TABLE Employee (name VARCHAR, salary VARCHAR, eid VARCHAR)

Answer: [SQL] SELECT T1.name, T1.salary FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid GROUP BY T1.eid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the salary and name of the employee who has the most number of certificates on aircrafts with distance more than 5000?

Context: CREATE TABLE Aircraft (aid VARCHAR, distance INTEGER); CREATE TABLE Employee (name VARCHAR, eid VARCHAR); CREATE TABLE Certificate (eid VARCHAR, aid VARCHAR)

Answer: [SQL] SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid = T2.eid JOIN Aircraft AS T3 ON T3.aid = T2.aid WHERE T3.distance > 5000 GROUP BY T1.eid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many allergies are there?

Context: CREATE TABLE Allergy_type (allergy VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT allergy) FROM Allergy_type [/SQL]


Question: How many different allergy types exist?

Context: CREATE TABLE Allergy_type (allergytype VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT allergytype) FROM Allergy_type [/SQL]


Question: Show all allergy types.

Answer: [SQL] SELECT DISTINCT allergytype FROM Allergy_type [/SQL]


Question: Show all allergies and their types.

Context: CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR)

Answer: [SQL] SELECT allergy, allergytype FROM Allergy_type [/SQL]


Question: Show all allergies with type food.

Answer: [SQL] SELECT DISTINCT allergy FROM Allergy_type WHERE allergytype = "food" [/SQL]


Question: What is the type of allergy Cat?

Context: CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR)

Answer: [SQL] SELECT allergytype FROM Allergy_type WHERE allergy = "Cat" [/SQL]


Question: How many allergies have type animal?

Answer: [SQL] SELECT COUNT(*) FROM Allergy_type WHERE allergytype = "animal" [/SQL]


Question: Show all allergy types and the number of allergies in each type.

Answer: [SQL] SELECT allergytype, COUNT(*) FROM Allergy_type GROUP BY allergytype [/SQL]


Question: Which allergy type has most number of allergies?

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


Question: Which allergy type has least number of allergies?

Answer: [SQL] SELECT allergytype FROM Allergy_type GROUP BY allergytype ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: How many students are there?

Context: CREATE TABLE Student (Id VARCHAR)

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


Question: Show first name and last name for all students.

Context: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR)

Answer: [SQL] SELECT Fname, Lname FROM Student [/SQL]


Question: How many different advisors are listed?

Context: CREATE TABLE Student (advisor VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT advisor) FROM Student [/SQL]


Question: Show all majors.

Context: CREATE TABLE Student (Major VARCHAR)

Answer: [SQL] SELECT DISTINCT Major FROM Student [/SQL]


Question: Show all cities where students live.

Context: CREATE TABLE Student (city_code VARCHAR)

Answer: [SQL] SELECT DISTINCT city_code FROM Student [/SQL]


Question: Show first name, last name, age for all female students. Their sex is F.

Context: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, Age VARCHAR, Sex VARCHAR)

Answer: [SQL] SELECT Fname, Lname, Age FROM Student WHERE Sex = 'F' [/SQL]


Question: Show student ids for all male students.

Context: CREATE TABLE Student (StuID VARCHAR, Sex VARCHAR)

Answer: [SQL] SELECT StuID FROM Student WHERE Sex = 'M' [/SQL]


Question: How many students are age 18?

Context: CREATE TABLE Student (age VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Student WHERE age = 18 [/SQL]


Question: Show all student ids who are older than 20.

Context: CREATE TABLE Student (StuID VARCHAR, age INTEGER)

Answer: [SQL] SELECT StuID FROM Student WHERE age > 20 [/SQL]


Question: Which city does the student whose last name is "Kim" live in?

Context: CREATE TABLE Student (city_code VARCHAR, LName VARCHAR)

Answer: [SQL] SELECT city_code FROM Student WHERE LName = "Kim" [/SQL]


Question: Who is the advisor of student with ID 1004?

Context: CREATE TABLE Student (Advisor VARCHAR, StuID VARCHAR)

Answer: [SQL] SELECT Advisor FROM Student WHERE StuID = 1004 [/SQL]


Question: How many students live in HKG or CHI?

Answer: [SQL] SELECT COUNT(*) FROM Student WHERE city_code = "HKG" OR city_code = "CHI" [/SQL]


Question: Show the minimum, average, and maximum age of all students.

Context: CREATE TABLE Student (age INTEGER)

Answer: [SQL] SELECT MIN(age), AVG(age), MAX(age) FROM Student [/SQL]


Question: What is the last name of the youngest student?

Context: CREATE TABLE Student (LName VARCHAR, age INTEGER)

Answer: [SQL] SELECT LName FROM Student WHERE age = (SELECT MIN(age) FROM Student) [/SQL]


Question: Show the student id of the oldest student.

Answer: [SQL] SELECT StuID FROM Student WHERE age = (SELECT MAX(age) FROM Student) [/SQL]


Question: Show all majors and corresponding number of students.

Context: CREATE TABLE Student (major VARCHAR)

Answer: [SQL] SELECT major, COUNT(*) FROM Student GROUP BY major [/SQL]


Question: Which major has most number of students?

Context: CREATE TABLE Student (major VARCHAR)

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


Question: Show all ages and corresponding number of students.

Context: CREATE TABLE Student (age VARCHAR)

Answer: [SQL] SELECT age, COUNT(*) FROM Student GROUP BY age [/SQL]


Question: Show the average age for male and female students.

Context: CREATE TABLE Student (sex VARCHAR, age INTEGER)

Answer: [SQL] SELECT AVG(age), sex FROM Student GROUP BY sex [/SQL]


Question: Show all cities and corresponding number of students.

Answer: [SQL] SELECT city_code, COUNT(*) FROM Student GROUP BY city_code [/SQL]


Question: Show all advisors and corresponding number of students.

Context: CREATE TABLE Student (advisor VARCHAR)

Answer: [SQL] SELECT advisor, COUNT(*) FROM Student GROUP BY advisor [/SQL]


Question: Which advisor has most number of students?

Context: CREATE TABLE Student (advisor VARCHAR)

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


Question: How many students have cat allergies?

Context: CREATE TABLE Has_allergy (Allergy VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Has_allergy WHERE Allergy = "Cat" [/SQL]


Question: Show all student IDs who have at least two allergies.

Context: CREATE TABLE Has_allergy (StuID VARCHAR)

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


Question: What are the student ids of students who don't have any allergies?

Context: CREATE TABLE Has_allergy (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR)

Answer: [SQL] SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy [/SQL]


Question: How many female students have milk or egg allergies?

Context: CREATE TABLE Student (StuID VARCHAR, sex VARCHAR); CREATE TABLE has_allergy (StuID VARCHAR, allergy VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.sex = "F" AND T1.allergy = "Milk" OR T1.allergy = "Eggs" [/SQL]


Question: How many students have a food allergy?

Context: CREATE TABLE Has_allergy (allergy VARCHAR); CREATE TABLE Allergy_type (allergy VARCHAR, allergytype VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "food" [/SQL]


Question: Which allergy has most number of students affected?

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


Question: Show all allergies with number of students affected.

Answer: [SQL] SELECT Allergy, COUNT(*) FROM Has_allergy GROUP BY Allergy [/SQL]


Question: Show all allergy type with number of students affected.

Context: CREATE TABLE Has_allergy (allergy VARCHAR); CREATE TABLE Allergy_type (allergytype VARCHAR, allergy VARCHAR)

Answer: [SQL] SELECT T2.allergytype, COUNT(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype [/SQL]


Question: Find the last name and age of the student who has allergy to both milk and cat.

Context: CREATE TABLE Has_allergy (lname VARCHAR, age VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Student (lname VARCHAR, age VARCHAR, StuID VARCHAR, Allergy VARCHAR)

Answer: [SQL] SELECT lname, age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat") [/SQL]


Question: What are the allergies and their types that the student with first name Lisa has? And order the result by name of allergies.

Context: CREATE TABLE Has_allergy (Allergy VARCHAR, StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR, Fname VARCHAR); CREATE TABLE Allergy_type (Allergy VARCHAR, AllergyType VARCHAR)

Answer: [SQL] SELECT T1.Allergy, T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = "Lisa" ORDER BY T1.Allergy [/SQL]


Question: Find the first name and gender of the student who has allergy to milk but not cat.

Context: CREATE TABLE Student (fname VARCHAR, sex VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Has_allergy (fname VARCHAR, sex VARCHAR, StuID VARCHAR, Allergy VARCHAR)

Answer: [SQL] SELECT fname, sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy = "Cat") [/SQL]


Question: Find the average age of the students who have allergies with food and animal types.

Context: CREATE TABLE Student (age INTEGER, StuID VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (StuID VARCHAR, Allergy VARCHAR)

Answer: [SQL] SELECT AVG(age) FROM Student WHERE StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "animal") [/SQL]


Question: List the first and last name of the students who do not have any food type allergy.

Context: CREATE TABLE Student (fname VARCHAR, lname VARCHAR, StuID VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (StuID VARCHAR, Allergy VARCHAR)

Answer: [SQL] SELECT fname, lname FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") [/SQL]


Question: Find the number of male (sex is 'M') students who have some food type allery.

Context: CREATE TABLE Has_allergy (Allergy VARCHAR); CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Student (sex VARCHAR, StuID VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Student WHERE sex = "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") [/SQL]


Question: Find the different first names and cities of the students who have allergy to milk or cat.

Context: CREATE TABLE Has_Allergy (stuid VARCHAR, Allergy VARCHAR); CREATE TABLE Student (fname VARCHAR, city_code VARCHAR, stuid VARCHAR)

Answer: [SQL] SELECT DISTINCT T1.fname, T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid = T2.stuid WHERE T2.Allergy = "Milk" OR T2.Allergy = "Cat" [/SQL]


Question: Find the number of students who are older than 18 and do not have allergy to either food or animal.

Context: CREATE TABLE Allergy_Type (Allergy VARCHAR, allergytype VARCHAR); CREATE TABLE Has_allergy (Allergy VARCHAR); CREATE TABLE Student (age VARCHAR, StuID VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Student WHERE age > 18 AND NOT StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" OR T2.allergytype = "animal") [/SQL]


Question: Find the first name and major of the students who are not allegry to soy.

Context: CREATE TABLE Has_allergy (fname VARCHAR, major VARCHAR, StuID VARCHAR, Allergy VARCHAR); CREATE TABLE Student (fname VARCHAR, major VARCHAR, StuID VARCHAR, Allergy VARCHAR)

Answer: [SQL] SELECT fname, major FROM Student WHERE NOT StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy = "Soy") [/SQL]


Question: A list of the top 5 countries by number of invoices. List country name and number of invoices.

Context: CREATE TABLE invoices (billing_country VARCHAR)

Answer: [SQL] SELECT billing_country, COUNT(*) FROM invoices GROUP BY billing_country ORDER BY COUNT(*) DESC LIMIT 5 [/SQL]


Question: A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size.

Context: CREATE TABLE invoices (billing_country VARCHAR, total INTEGER)

Answer: [SQL] SELECT billing_country, SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8 [/SQL]


Question: A list of the top 10 countries by average invoice size. List country name and average invoice size.

Answer: [SQL] SELECT billing_country, AVG(total) FROM invoices GROUP BY billing_country ORDER BY AVG(total) DESC LIMIT 10 [/SQL]


Question: Find out 5 customers who most recently purchased something. List customers' first and last name.

Context: CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE invoices (customer_id VARCHAR, invoice_date VARCHAR)

Answer: [SQL] SELECT T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY T2.invoice_date DESC LIMIT 5 [/SQL]


Question: Find out the top 10 customers by total number of orders. List customers' first and last name and the number of total orders.

Context: CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE invoices (customer_id VARCHAR)

Answer: [SQL] SELECT T1.first_name, T1.last_name, COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 10 [/SQL]


Question: List the top 10 customers by total gross sales. List customers' first and last name and total gross sales.

Context: CREATE TABLE invoices (total INTEGER, customer_id VARCHAR); CREATE TABLE customers (first_name VARCHAR, last_name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.first_name, T1.last_name, SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC LIMIT 10 [/SQL]


Question: List the top 5 genres by number of tracks. List genres name and total tracks.

Context: CREATE TABLE tracks (genre_id VARCHAR); CREATE TABLE genres (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.name, COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id = T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 5 [/SQL]


Question: List every album's title.

Context: CREATE TABLE albums (title VARCHAR)

Answer: [SQL] SELECT title FROM albums [/SQL]


Question: List every album ordered by album title in ascending order.

Context: CREATE TABLE albums (title VARCHAR)

Answer: [SQL] SELECT title FROM albums ORDER BY title [/SQL]


Question: List every album whose title starts with A in alphabetical order.

Context: CREATE TABLE albums (title VARCHAR)

Answer: [SQL] SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY title [/SQL]


Question: List the customers first and last name of 10 least expensive invoices.

Answer: [SQL] SELECT T1.first_name, T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id = T1.id ORDER BY total LIMIT 10 [/SQL]


Question: List total amount of  invoice from Chicago, IL.

Context: CREATE TABLE invoices (total INTEGER, billing_city VARCHAR, billing_state VARCHAR)

Answer: [SQL] SELECT SUM(total) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL" [/SQL]


Question: List the number of invoices from Chicago, IL.

Context: CREATE TABLE invoices (billing_city VARCHAR, billing_state VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM invoices WHERE billing_city = "Chicago" AND billing_state = "IL" [/SQL]


Question: List the number of invoices from the US, grouped by state.

Context: CREATE TABLE invoices (billing_state VARCHAR, billing_country VARCHAR)

Answer: [SQL] SELECT billing_state, COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state [/SQL]


Question: List the state in the US with the most invoices.

Answer: [SQL] SELECT billing_state, COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the number of invoices and the invoice total from California.

Context: CREATE TABLE invoices (billing_state VARCHAR, total INTEGER)

Answer: [SQL] SELECT billing_state, COUNT(*), SUM(total) FROM invoices WHERE billing_state = "CA" [/SQL]


Question: List Aerosmith's albums.

Context: CREATE TABLE artists (id VARCHAR, name VARCHAR); CREATE TABLE albums (title VARCHAR, artist_id VARCHAR)

Answer: [SQL] SELECT T1.title FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Aerosmith" [/SQL]


Question: How many albums does Billy Cobham has?

Context: CREATE TABLE artists (id VARCHAR, name VARCHAR); CREATE TABLE albums (artist_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM albums AS T1 JOIN artists AS T2 ON T1.artist_id = T2.id WHERE T2.name = "Billy Cobham" [/SQL]


Question: Eduardo Martins is a customer at which company?

Context: CREATE TABLE customers (company VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT company FROM customers WHERE first_name = "Eduardo" AND last_name = "Martins" [/SQL]


Question: What is Astrid Gruber's email and phone number?

Context: CREATE TABLE customers (email VARCHAR, phone VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT email, phone FROM customers WHERE first_name = "Astrid" AND last_name = "Gruber" [/SQL]


Question: How many customers live in Prague city?

Context: CREATE TABLE customers (city VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers WHERE city = "Prague" [/SQL]


Question: How many customers in state of CA?

Context: CREATE TABLE customers (state VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers WHERE state = "CA" [/SQL]


Question: What country does Roberto Almeida live?

Context: CREATE TABLE customers (country VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT country FROM customers WHERE first_name = "Roberto" AND last_name = "Almeida" [/SQL]


Question: List the name of albums that are released by aritist whose name has 'Led'

Answer: [SQL] SELECT T2.title FROM artists AS T1 JOIN albums AS T2 ON T1.id = T2.artist_id WHERE T1.name LIKE '%Led%' [/SQL]


Question: How many customers does Steve Johnson support?

Context: CREATE TABLE employees (id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE customers (support_rep_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = "Steve" AND T1.last_name = "Johnson" [/SQL]


Question: What is the title, phone and hire date of Nancy Edwards?

Context: CREATE TABLE employees (title VARCHAR, phone VARCHAR, hire_date VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT title, phone, hire_date FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards" [/SQL]


Question: find the full name of employees who report to Nancy Edwards?

Context: CREATE TABLE employees (id VARCHAR, first_name VARCHAR, last_name VARCHAR); CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, reports_to VARCHAR)

Answer: [SQL] SELECT T2.first_name, T2.last_name FROM employees AS T1 JOIN employees AS T2 ON T1.id = T2.reports_to WHERE T1.first_name = "Nancy" AND T1.last_name = "Edwards" [/SQL]


Question: What is the address of employee Nancy Edwards?

Context: CREATE TABLE employees (address VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT address FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards" [/SQL]


Question: Find the full name of employee who supported the most number of customers.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE customers (support_rep_id VARCHAR)

Answer: [SQL] SELECT T1.first_name, T1.last_name FROM employees AS T1 JOIN customers AS T2 ON T1.id = T2.support_rep_id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: How many employees are living in Canada?

Context: CREATE TABLE employees (country VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM employees WHERE country = "Canada" [/SQL]


Question: What is employee Nancy Edwards's phone number?

Context: CREATE TABLE employees (phone VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT phone FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards" [/SQL]


Question: Who is the youngest employee in the company? List employee's first and last name.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, birth_date VARCHAR)

Answer: [SQL] SELECT first_name, last_name FROM employees ORDER BY birth_date DESC LIMIT 1 [/SQL]


Question: List top 10 employee work longest in the company. List employee's first and last name.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, hire_date VARCHAR)

Answer: [SQL] SELECT first_name, last_name FROM employees ORDER BY hire_date LIMIT 10 [/SQL]


Question: Find the number of employees whose title is IT Staff from each city?

Context: CREATE TABLE employees (city VARCHAR, title VARCHAR)

Answer: [SQL] SELECT COUNT(*), city FROM employees WHERE title = 'IT Staff' GROUP BY city [/SQL]


Question: Which employee manage most number of peoples? List employee's first and last name, and number of people report to that employee.

Context: CREATE TABLE employees (first_name VARCHAR, last_name VARCHAR, id VARCHAR); CREATE TABLE employees (reports_to VARCHAR)

Answer: [SQL] SELECT T2.first_name, T2.last_name, COUNT(T1.reports_to) FROM employees AS T1 JOIN employees AS T2 ON T1.reports_to = T2.id GROUP BY T1.reports_to ORDER BY COUNT(T1.reports_to) DESC LIMIT 1 [/SQL]


Question: How many orders does Lucas Mancini has?

Context: CREATE TABLE invoices (customer_id VARCHAR); CREATE TABLE customers (id VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini" [/SQL]


Question: What is the total amount of money spent by Lucas Mancini?

Context: CREATE TABLE invoices (total INTEGER, customer_id VARCHAR); CREATE TABLE customers (id VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T1.id = T2.customer_id WHERE T1.first_name = "Lucas" AND T1.last_name = "Mancini" [/SQL]


Question: List all media types.

Context: CREATE TABLE media_types (name VARCHAR)

Answer: [SQL] SELECT name FROM media_types [/SQL]


Question: List all different genre types.

Context: CREATE TABLE genres (name VARCHAR)

Answer: [SQL] SELECT DISTINCT name FROM genres [/SQL]


Question: List the name of all playlist.

Context: CREATE TABLE playlists (name VARCHAR)

Answer: [SQL] SELECT name FROM playlists [/SQL]


Question: Who is the composer of track Fast As a Shark?

Context: CREATE TABLE tracks (composer VARCHAR, name VARCHAR)

Answer: [SQL] SELECT composer FROM tracks WHERE name = "Fast As a Shark" [/SQL]


Question: How long does track Fast As a Shark has?

Context: CREATE TABLE tracks (milliseconds VARCHAR, name VARCHAR)

Answer: [SQL] SELECT milliseconds FROM tracks WHERE name = "Fast As a Shark" [/SQL]


Question: What is the name of tracks whose genre is Rock?

Context: CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR)

Answer: [SQL] SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock" [/SQL]


Question: What is title of album which track Balls to the Wall belongs to?

Context: CREATE TABLE tracks (genre_id VARCHAR, name VARCHAR); CREATE TABLE albums (title VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T2.name = "Balls to the Wall" [/SQL]


Question: List name of all tracks in Balls to the Wall.

Context: CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR); CREATE TABLE albums (id VARCHAR, title VARCHAR)

Answer: [SQL] SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall" [/SQL]


Question: List title of albums have the number of tracks greater than 10.

Context: CREATE TABLE tracks (album_id VARCHAR); CREATE TABLE albums (title VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.title FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.album_id GROUP BY T1.id HAVING COUNT(T1.id) > 10 [/SQL]


Question: List the name of tracks belongs to genre Rock and whose media type is MPEG audio file.

Context: CREATE TABLE genres (id VARCHAR, name VARCHAR); CREATE TABLE tracks (name VARCHAR, genre_id VARCHAR, media_type_id VARCHAR); CREATE TABLE media_types (id VARCHAR, name VARCHAR)

Answer: [SQL] SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" AND T3.name = "MPEG audio file" [/SQL]


Question: List the name of tracks belongs to genre Rock or media type is MPEG audio file.

Answer: [SQL] SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id JOIN media_types AS T3 ON T3.id = T2.media_type_id WHERE T1.name = "Rock" OR T3.name = "MPEG audio file" [/SQL]


Question: List the name of tracks belongs to genre Rock or genre Jazz.

Answer: [SQL] SELECT T2.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.name = "Rock" OR T1.name = "Jazz" [/SQL]


Question: List the name of all tracks in the playlists of Movies.

Context: CREATE TABLE playlists (id VARCHAR, name VARCHAR); CREATE TABLE playlist_tracks (track_id VARCHAR, playlist_id VARCHAR); CREATE TABLE tracks (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T3.id = T2.playlist_id WHERE T3.name = "Movies" [/SQL]


Question: List the name of playlist which has number of tracks greater than 100.

Context: CREATE TABLE playlist_tracks (playlist_id VARCHAR, track_id VARCHAR); CREATE TABLE playlists (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT T2.name FROM playlist_tracks AS T1 JOIN playlists AS T2 ON T2.id = T1.playlist_id GROUP BY T1.playlist_id HAVING COUNT(T1.track_id) > 100 [/SQL]


Question: List all tracks bought by customer Daan Peeters.

Context: CREATE TABLE invoices (id VARCHAR, customer_id VARCHAR); CREATE TABLE invoice_lines (track_id VARCHAR, invoice_id VARCHAR); CREATE TABLE tracks (name VARCHAR, id VARCHAR); CREATE TABLE customers (id VARCHAR, first_name VARCHAR, last_name VARCHAR)

Answer: [SQL] SELECT T1.name FROM tracks AS T1 JOIN invoice_lines AS T2 ON T1.id = T2.track_id JOIN invoices AS T3 ON T3.id = T2.invoice_id JOIN customers AS T4 ON T4.id = T3.customer_id WHERE T4.first_name = "Daan" AND T4.last_name = "Peeters" [/SQL]


Question: How much is the track Fast As a Shark?

Context: CREATE TABLE tracks (unit_price VARCHAR, name VARCHAR)

Answer: [SQL] SELECT unit_price FROM tracks WHERE name = "Fast As a Shark" [/SQL]


Question: Find the name of tracks which are in Movies playlist but not in music playlist.

Answer: [SQL] SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' EXCEPT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music' [/SQL]


Question: Find the name of tracks which are in both Movies and music playlists.

Answer: [SQL] SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Movies' INTERSECT SELECT T1.name FROM tracks AS T1 JOIN playlist_tracks AS T2 ON T1.id = T2.track_id JOIN playlists AS T3 ON T2.playlist_id = T3.id WHERE T3.name = 'Music' [/SQL]


Question: Find number of tracks in each genre?

Context: CREATE TABLE tracks (genre_id VARCHAR); CREATE TABLE genres (name VARCHAR, id VARCHAR)

Answer: [SQL] SELECT COUNT(*), T1.name FROM genres AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id GROUP BY T1.name [/SQL]


Question: How many editors are there?

Context: CREATE TABLE editor (Id VARCHAR)

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


Question: List the names of editors in ascending order of age.

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

Answer: [SQL] SELECT Name FROM editor ORDER BY Age [/SQL]


Question: What are the names and ages of editors?

Answer: [SQL] SELECT Name, Age FROM editor [/SQL]


Question: List the names of editors who are older than 25.

Context: CREATE TABLE editor (Name VARCHAR, Age INTEGER)

Answer: [SQL] SELECT Name FROM editor WHERE Age > 25 [/SQL]


Question: Show the names of editors of age either 24 or 25.

Answer: [SQL] SELECT Name FROM editor WHERE Age = 24 OR Age = 25 [/SQL]


Question: What is the name of the youngest editor?

Answer: [SQL] SELECT Name FROM editor ORDER BY Age LIMIT 1 [/SQL]


Question: What are the different ages of editors? Show each age along with the number of editors of that age.

Context: CREATE TABLE editor (Age VARCHAR)

Answer: [SQL] SELECT Age, COUNT(*) FROM editor GROUP BY Age [/SQL]


Question: Please show the most common age of editors.

Context: CREATE TABLE editor (Age VARCHAR)

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