diff --git a/data/questions_gen.csv b/data/questions_gen.csv index 9c5b6e8..0f0b758 100644 --- a/data/questions_gen.csv +++ b/data/questions_gen.csv @@ -4,76 +4,76 @@ What is the average number of citations received by publications in each year?," What is the total number of publications that cite each publication?,"WITH cited_pubs AS (SELECT cite.cited AS publication_id, COUNT(*) AS total_citations FROM cite GROUP BY cite.cited ORDER BY total_citations DESC NULLS LAST) SELECT COUNT(*) FROM cited_pubs WHERE total_citations > 0;",academic,group_by What is the total number of publications published in each year?,"SELECT publication.year, COUNT(DISTINCT publication.pid) AS total_publications FROM publication GROUP BY publication.year ORDER BY publication.year;",academic,group_by What is the average number of references cited by publications in each domain name?,"SELECT {domain.name,domain.did}, AVG(publication.reference_num) as average_references FROM domain_publication JOIN publication ON domain_publication.pid = publication.pid JOIN domain ON domain.did = domain_publication.did GROUP BY 1;",academic,group_by -What are the top 3 publications with the highest number of citations?,"SELECT publication.title, publication.citation_num FROM publication ORDER BY publication.citation_num DESC LIMIT 3;",academic,order_by +What are the top 3 publications with the highest number of citations?,"SELECT {publication.title, publication.pid}, publication.citation_num FROM publication ORDER BY publication.citation_num DESC LIMIT 3;",academic,order_by What is the title of the publication that has received the highest number of citations?,SELECT publication.title FROM publication ORDER BY publication.citation_num DESC NULLS LAST LIMIT 1;,academic,order_by What are the titles of all publications ordered alphabetically?,SELECT DISTINCT publication.title FROM publication ORDER BY publication.title ASC NULLS LAST;,academic,order_by "What are the top 3 titles of the publications that have the highest number of references cited, ordered by the number of references cited in descending order?","SELECT publication.title, publication.reference_num FROM publication ORDER BY publication.reference_num DESC LIMIT 3;",academic,order_by -What are the top 5 domains with the highest number of authors associated with them?,"SELECT d.name, COUNT(DISTINCT a.aid) as author_count FROM author a JOIN domain_author da ON a.aid = da.aid JOIN domain d ON da.did = d.did GROUP BY d.name ORDER BY author_count DESC, d.name LIMIT 5;",academic,order_by +What are the top 5 domains with the highest number of authors associated with them?,"SELECT {d.name, d.did}, COUNT(DISTINCT a.aid) as author_count FROM author a JOIN domain_author da ON a.aid = da.aid JOIN domain d ON da.did = d.did GROUP BY {} ORDER BY author_count DESC, d.name LIMIT 5;",academic,order_by What is the ratio of publications to authors in the database?,"SELECT CAST(COUNT(DISTINCT publication.pid) AS FLOAT) / NULLIF(COUNT(DISTINCT author.aid), 0) AS publication_to_author_ratio FROM publication, author;",academic,ratio -How does the ratio of publications to keywords vary across different domains?,"SELECT domain_publication.did, CAST(COUNT(DISTINCT domain_publication.pid) AS FLOAT) / NULLIF(COUNT(DISTINCT domain_keyword.kid), 0) AS publication_to_keyword_ratio FROM domain_publication JOIN domain_keyword ON domain_publication.did = domain_keyword.did GROUP BY domain_publication.did ORDER BY publication_to_keyword_ratio DESC NULLS LAST;",academic,ratio +How does the ratio of publications to keywords vary across different domain ids?,"SELECT domain_publication.did, CAST(COUNT(DISTINCT domain_publication.pid) AS FLOAT) / NULLIF(COUNT(DISTINCT domain_keyword.kid), 0) AS publication_to_keyword_ratio FROM domain_publication JOIN domain_keyword ON domain_publication.did = domain_keyword.did GROUP BY domain_publication.did ORDER BY publication_to_keyword_ratio DESC NULLS LAST;",academic,ratio How does the ratio of authors to organizations differ by continent?,"SELECT organization.continent, COUNT(DISTINCT author.aid)::float / NULLIF(COUNT(DISTINCT organization.oid), 0) AS ratio FROM author JOIN organization ON author.oid = organization.oid GROUP BY organization.continent ORDER BY ratio DESC NULLS LAST;",academic,ratio How does the ratio of publications to journals change over the years? Return the annual numbers of publications and journals as well.,"SELECT publication.year, COUNT(DISTINCT publication.pid) AS num_publications, COUNT(DISTINCT publication.jid) AS num_journals, CAST(COUNT(DISTINCT publication.pid) AS FLOAT) / NULLIF(COUNT(DISTINCT publication.jid), 0) AS ratio FROM publication GROUP BY publication.year ORDER BY publication.year;",academic,ratio What is the ratio of publications presented in conferences to publications published in journals?,"SELECT CAST(COUNT(DISTINCT publication.cid) AS FLOAT) / NULLIF(COUNT(DISTINCT publication.jid), 0) AS ratio FROM publication;",academic,ratio "How many publications were presented at each conference, ordered by the number of publications in descending order? Give the names of the conferences and their corresponding number of publications.","SELECT conference.name, COUNT(publication.pid) AS num_publications FROM publication JOIN conference ON publication.cid=conference.cid GROUP BY conference.cid ORDER BY num_publications DESC NULLS LAST;",academic,table_join -"What is the total number of publications in each journal, ordered by the number of publications in descending order?","SELECT journal.name, COUNT(publication.pid) AS total_publications FROM publication JOIN journal ON publication.jid=journal.jid GROUP BY journal.name ORDER BY total_publications DESC NULLS LAST;",academic,table_join -How does the ratio of citations to publications vary across different domains?,"SELECT domain.name, SUM(publication.citation_num)::float / NULLIF(COUNT(DISTINCT domain_publication.pid), 0) AS citation_to_publication_ratio FROM domain JOIN domain_publication ON domain.did = domain_publication.did JOIN publication ON domain_publication.pid = publication.pid GROUP BY domain.name ORDER BY citation_to_publication_ratio DESC NULLS LAST;",academic,table_join -Which author had the most publications in the year 2021?,"SELECT author.name, COUNT(publication.pid) AS publication_count FROM writes JOIN author ON writes.aid = author.aid JOIN publication ON writes.pid = publication.pid WHERE publication.year = 2021 GROUP BY author.name ORDER BY publication_count DESC NULLS LAST LIMIT 1; ",academic,table_join -What is the total number of publications presented in each conference?,"SELECT conference.name, COUNT(publication.pid) AS total_publications FROM publication JOIN conference ON publication.cid = conference.cid GROUP BY conference.name ORDER BY total_publications DESC;",academic,table_join -Which authors are not part of any organization?,SELECT DISTINCT name FROM author WHERE oid IS NULL,academic,where +"What is the total number of publications in each journal, ordered by the number of publications in descending order?","SELECT {journal.name, journal.jid}, COUNT(publication.pid) AS total_publications FROM publication JOIN journal ON publication.jid=journal.jid GROUP BY {} ORDER BY total_publications DESC NULLS LAST;",academic,table_join +How does the ratio of citations to publications vary across different domains?,"SELECT {domain.name, domain.did}, SUM(publication.citation_num)::float / NULLIF(COUNT(DISTINCT domain_publication.pid), 0) AS citation_to_publication_ratio FROM domain JOIN domain_publication ON domain.did = domain_publication.did JOIN publication ON domain_publication.pid = publication.pid GROUP BY {} ORDER BY citation_to_publication_ratio DESC NULLS LAST;",academic,table_join +Which author had the most publications in the year 2021?,"SELECT {author.name, author.aid}, COUNT(publication.pid) AS publication_count FROM writes JOIN author ON writes.aid = author.aid JOIN publication ON writes.pid = publication.pid WHERE publication.year = 2021 GROUP BY {} ORDER BY publication_count DESC NULLS LAST LIMIT 1; ",academic,table_join +What is the total number of publications presented in each conference?,"SELECT {conference.name, conference.cid}, COUNT(publication.pid) AS total_publications FROM publication JOIN conference ON publication.cid = conference.cid GROUP BY {} ORDER BY total_publications DESC;",academic,table_join +Which authors are not part of any organization?,SELECT DISTINCT {name, aid} FROM author WHERE oid IS NULL,academic,where "What are the names of the authors who have written publications in the domain ""Computer Science""?",SELECT DISTINCT author.name FROM author join writes ON author.aid = writes.aid join publication ON writes.pid = publication.pid join domain_publication ON publication.pid = domain_publication.pid join domain ON domain_publication.did = domain.did WHERE domain.name ilike '%computer%science%';,academic,where -"Which organizations have authors who have written publications in the domain ""Machine Learning""?",SELECT DISTINCT organization.name FROM organization JOIN author ON organization.oid = author.oid JOIN writes ON author.aid = writes.aid JOIN domain_publication ON writes.pid = domain_publication.pid JOIN domain ON domain_publication.did = domain.did WHERE domain.name = 'Machine Learning';,academic,where -Which authors belong to the same domain as Martin?,SELECT DISTINCT a2.name FROM author a1 JOIN domain_author da1 ON a1.aid = da1.aid JOIN domain_author da2 ON da1.did = da2.did JOIN author a2 ON da2.aid = a2.aid WHERE LOWER(a1.name) LIKE '%martin%';,academic,where -What are the publications written by authors from the 'Artificial Intelligence' domain and presented at conferences in the year 2020?,SELECT DISTINCT publication.title FROM domain JOIN domain_author ON domain.did = domain_author.did JOIN writes ON domain_author.aid = writes.aid JOIN publication ON writes.pid = publication.pid JOIN domain_conference ON domain.did = domain_conference.did WHERE domain.name = 'Artificial Intelligence' AND publication.year = 2020 AND publication.cid = domain_conference.cid;,academic,where -How many courses are offered in each semester?,"SELECT course_offering.semester, COUNT(DISTINCT course_offering.course_id) AS num_courses FROM course_offering GROUP BY course_offering.semester ORDER BY course_offering.semester;",advising,group_by +"Which organizations have authors who have written publications in the domain ""Machine Learning""?",SELECT DISTINCT {organization.name, organization.oid} FROM organization JOIN author ON organization.oid = author.oid JOIN writes ON author.aid = writes.aid JOIN domain_publication ON writes.pid = domain_publication.pid JOIN domain ON domain_publication.did = domain.did WHERE domain.name = 'Machine Learning';,academic,where +Which authors belong to the same domain as Martin?,SELECT DISTINCT {a2.name, a2.aid} FROM author a1 JOIN domain_author da1 ON a1.aid = da1.aid JOIN domain_author da2 ON da1.did = da2.did JOIN author a2 ON da2.aid = a2.aid WHERE LOWER(a1.name) LIKE '%martin%';,academic,where +What are the publications written by authors from the 'Artificial Intelligence' domain and presented at conferences in the year 2020?,SELECT DISTINCT {publication.title, publication.pid} FROM domain JOIN domain_author ON domain.did = domain_author.did JOIN writes ON domain_author.aid = writes.aid JOIN publication ON writes.pid = publication.pid JOIN domain_conference ON domain.did = domain_conference.did WHERE domain.name = 'Artificial Intelligence' AND publication.year = 2020 AND publication.cid = domain_conference.cid;,academic,where +How many courses are offered in each semester id?,"SELECT course_offering.semester, COUNT(DISTINCT course_offering.course_id) AS num_courses FROM course_offering GROUP BY course_offering.semester ORDER BY course_offering.semester;",advising,group_by How many courses have a final exam and how many do not?,"SELECT course_offering.has_final_exam, COUNT(*) AS num_courses FROM course_offering GROUP BY course_offering.has_final_exam;",advising,group_by -What is the total number of students who found the instructor to be hilarious per course?,"SELECT course_tags_count.course_id, SUM(course_tags_count.hilarious) AS total_hilarious FROM course_tags_count GROUP BY course_tags_count.course_id;",advising,group_by +What is the total number of students who found the instructor to be hilarious per course id?,"SELECT course_tags_count.course_id, SUM(course_tags_count.hilarious) AS total_hilarious FROM course_tags_count GROUP BY course_tags_count.course_id;",advising,group_by How many courses does each department offer?,"SELECT course.department, COUNT(DISTINCT course.course_id) AS num_courses FROM course GROUP BY course.department ORDER BY num_courses DESC NULLS LAST;",advising,group_by -What is the average clarity score for each instructor who taught a course before?,"SELECT instructor.name, AVG(comment_instructor.score) as average_score FROM comment_instructor JOIN instructor ON comment_instructor.instructor_id = instructor.instructor_id GROUP BY instructor.name ORDER BY average_score DESC NULLS LAST;",advising,group_by -"What is the total number of students enrolled in each course, ordered from highest to lowest?","SELECT course.course_id, SUM(course.num_enrolled) AS total_students FROM course GROUP BY course.course_id ORDER BY total_students DESC NULLS LAST;",advising,order_by -"Which course has the highest number of enrolled students, and what is the enrollment number?","SELECT course.name, course.num_enrolled FROM course ORDER BY course.num_enrolled DESC NULLS LAST LIMIT 1;",advising,order_by -"What is the total number of credits earned by each student, ordered from highest to lowest? Give the student id and the total number of credits.","SELECT student.student_id, student.total_credit FROM student ORDER BY student.total_credit DESC NULLS LAST;",advising,order_by +What is the average clarity score for each instructor who taught a course?,"SELECT instructor.name, AVG(comment_instructor.score) as average_score FROM comment_instructor JOIN instructor ON comment_instructor.instructor_id = instructor.instructor_id GROUP BY instructor.name ORDER BY average_score DESC NULLS LAST;",advising,group_by +"What is the total number of students enrolled in each course, ordered from highest to lowest?","SELECT {course.course_id, course.name}, SUM(course.num_enrolled) AS total_students FROM course GROUP BY {} ORDER BY total_students DESC NULLS LAST;",advising,order_by +"Which course has the highest number of enrolled students, and what is the enrollment number?","SELECT {course.name, course.course_id}, course.num_enrolled FROM course ORDER BY course.num_enrolled DESC NULLS LAST LIMIT 1;",advising,order_by +"What is the total number of credits earned by each student, ordered from highest to lowest? Give the student id and the total number of credits.","SELECT {student.student_id, student.lastname, student.firstname}, student.total_credit FROM student ORDER BY student.total_credit DESC NULLS LAST;",advising,order_by "What is the name of the instructor who has taught the most courses, and how many courses have they taught?","SELECT instructor.name, count(offering_instructor.offering_id) as num_courses FROM offering_instructor JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id GROUP BY instructor.name ORDER BY num_courses DESC LIMIT 1;",advising,order_by "What is the total number of students who participated actively in each course, ordered from highest to lowest?","SELECT course_tags_count.course_id, course_tags_count.participation FROM course_tags_count ORDER BY course_tags_count.participation DESC NULLS LAST;",advising,order_by What is the ratio of helpfulness scores to clarity scores for each course?,"SELECT course.course_id, CAST(course.helpfulness_score AS FLOAT) / NULLIF(course.clarity_score, 0) AS ratio FROM course;",advising,ratio -How does the ratio of enrolled students to the number of reviews vary across different courses?,"SELECT course.course_id, CAST(course.num_enrolled AS FLOAT) / NULLIF(course.num_reviews, 0) AS student_review_ratio FROM course ORDER BY student_review_ratio NULLS LAST;",advising,ratio -What is the ratio of the number of courses with projects to the number of courses with exams in each semester?,"SELECT course_offering.semester, CAST(SUM(CASE WHEN course.has_projects THEN 1 ELSE 0 END) AS FLOAT) / NULLIF(SUM(CASE WHEN course.has_exams THEN 1 ELSE 0 END), 0) AS ratio FROM course JOIN course_offering ON course.course_id = course_offering.course_id GROUP BY course_offering.semester ORDER BY course_offering.semester NULLS LAST;",advising,ratio -What is the ratio of the number of students who found the grading criteria clear and easy to understand to the number of students who received good feedback from the instructor for each course?,"SELECT course_tags_count.course_id, CAST(course_tags_count.clear_grading AS FLOAT) / NULLIF(course_tags_count.good_feedback, 0) AS ratio FROM course_tags_count ORDER BY course_tags_count.course_id NULLS LAST;",advising,ratio +How does the ratio of enrolled students to the number of reviews vary across different courses?,"SELECT {course.course_id, course.name}, CAST(course.num_enrolled AS FLOAT) / NULLIF(course.num_reviews, 0) AS student_review_ratio FROM course ORDER BY student_review_ratio NULLS LAST;",advising,ratio +What is the ratio of the number of courses with projects to the number of courses with exams in each semester id?,"SELECT course_offering.semester, CAST(SUM(CASE WHEN course.has_projects THEN 1 ELSE 0 END) AS FLOAT) / NULLIF(SUM(CASE WHEN course.has_exams THEN 1 ELSE 0 END), 0) AS ratio FROM course JOIN course_offering ON course.course_id = course_offering.course_id GROUP BY course_offering.semester ORDER BY course_offering.semester NULLS LAST;",advising,ratio +What is the ratio of the number of students who found the grading criteria clear and easy to understand to the number of students who received good feedback from the instructor for each course id?,"SELECT course_tags_count.course_id, CAST(course_tags_count.clear_grading AS FLOAT) / NULLIF(course_tags_count.good_feedback, 0) AS ratio FROM course_tags_count ORDER BY course_tags_count.course_id NULLS LAST;",advising,ratio What is the ratio of the total number of students enrolled in courses with exams to the total number of students enrolled in courses without exams?,"SELECT CAST(SUM(CASE WHEN course.has_exams THEN course.num_enrolled ELSE 0 END) AS FLOAT) / NULLIF(SUM(CASE WHEN NOT course.has_exams THEN course.num_enrolled ELSE 0 END), 0) AS ratio FROM course;",advising,ratio -Which courses have a final project and a final exam?,SELECT DISTINCT course.name FROM course_offering JOIN course ON course_offering.course_id = course.course_id WHERE course_offering.has_final_project AND course_offering.has_final_exam;,advising,table_join -What is the total number of credits earned by students in each program?,"SELECT program.name, SUM(student.total_credit) AS total_credits FROM student JOIN program ON student.program_id = program.program_id GROUP BY program.name;",advising,table_join -How many students have declared a major in each program?,"SELECT program.name, COUNT(student.student_id) AS number_of_students FROM student JOIN program ON student.program_id = program.program_id WHERE student.declare_major IS NOT NULL GROUP BY program.name ORDER BY number_of_students DESC;",advising,table_join -Which courses have been taken by students in the Computer Science program?,SELECT DISTINCT course.name AS course_name FROM student JOIN student_record ON student.student_id = student_record.student_id JOIN program ON student.program_id = program.program_id JOIN course ON student_record.course_id = course.course_id WHERE program.name = 'Computer Science';,advising,table_join +Which courses have a final project and a final exam?,SELECT DISTINCT {course.name, course.course_id} FROM course_offering JOIN course ON course_offering.course_id = course.course_id WHERE course_offering.has_final_project AND course_offering.has_final_exam;,advising,table_join +What is the total number of credits earned by students in each program?,"SELECT {program.name, program.program_id}, SUM(student.total_credit) AS total_credits FROM student JOIN program ON student.program_id = program.program_id GROUP BY {};",advising,table_join +How many students have declared a major in each program?,"SELECT {program.name, program.program_id}, COUNT(student.student_id) AS number_of_students FROM student JOIN program ON student.program_id = program.program_id WHERE student.declare_major IS NOT NULL GROUP BY {} ORDER BY number_of_students DESC;",advising,table_join +Which courses have been taken by students in the Computer Science program?,SELECT DISTINCT {course.name, course.course_id} AS course_name FROM student JOIN student_record ON student.student_id = student_record.student_id JOIN program ON student.program_id = program.program_id JOIN course ON student_record.course_id = course.course_id WHERE program.name = 'Computer Science';,advising,table_join What is the total number of students who have taken a course with a final project or exam?,SELECT COUNT(DISTINCT student_record.student_id) AS total_students FROM student_record JOIN course_offering ON student_record.course_id = course_offering.course_id WHERE course_offering.has_final_project OR course_offering.has_final_exam;,advising,table_join How many students have taken a course in-person vs. online?,"SELECT student_record.how, COUNT(DISTINCT student_record.student_id) AS num_students FROM student_record WHERE student_record.how IN ('in-person', 'online') GROUP BY student_record.how;",advising,where -What are the names of all the courses offered by the department of Computer Science?,SELECT course.name FROM course WHERE course.department = 'Computer Science' ORDER BY course.name ASC NULLS LAST;,advising,where -"How many students have declared a minor program, and what are their names? Order the results by the students' last names.","SELECT student.firstname, student.lastname FROM student WHERE student.minor IS NOT NULL ORDER BY student.lastname NULLS LAST;",advising,where -"What are the individual ratios of easiness scores to helpfulness scores for courses in the ""Computer Science"" department? return the names and the ratios.","SELECT name, cast(course.easiness_score as float) / nullif(course.helpfulness_score, 0) as ratio FROM course WHERE course.department ilike '%Computer Science%';",advising,where +What are the names of all the courses offered by the department of Computer Science?,SELECT {course.name, course.course_id} FROM course WHERE course.department = 'Computer Science' ORDER BY course.name ASC NULLS LAST;,advising,where +"Which students have declared a minor program? List their firstname and lastname. Order the results by the students' last names.","SELECT student.firstname, student.lastname FROM student WHERE student.minor IS NOT NULL ORDER BY student.lastname NULLS LAST;",advising,where +"What are the individual ratios of easiness scores to helpfulness scores for courses in the ""Computer Science"" department? return the names and the ratios.","SELECT {name, course_id}, cast(course.easiness_score as float) / nullif(course.helpfulness_score, 0) as ratio FROM course WHERE course.department ilike '%Computer Science%';",advising,where "What is the average GPA of students in the program ""Computer Engineering""?",SELECT AVG(student.total_gpa) FROM student JOIN program ON student.program_id = program.program_id WHERE LOWER(program.name) LIKE '%computer engineering%';,advising,where -What is the total cost of round-trip fares for each airline?,"SELECT fare.fare_airline, SUM(fare.round_trip_cost) AS total_round_trip_cost FROM fare GROUP BY fare.fare_airline ORDER BY total_round_trip_cost DESC;",atis,group_by -How many flights are there from each airport?,"SELECT flight.from_airport, COUNT(*) AS number_of_flights FROM flight GROUP BY flight.from_airport ORDER BY number_of_flights ASC NULLS LAST;",atis,group_by -"What is the average cost of a one-way trip for each fare, sorted in ascending order?","SELECT fare.fare_id, AVG(fare.one_direction_cost) AS average_cost FROM fare GROUP BY fare.fare_id ORDER BY average_cost ASC NULLS LAST;",atis,group_by +What is the total cost of round-trip fares for each airline code?,"SELECT fare.fare_airline, SUM(fare.round_trip_cost) AS total_round_trip_cost FROM fare GROUP BY fare.fare_airline ORDER BY total_round_trip_cost DESC;",atis,group_by +How many flights are there from each airport code?,"SELECT flight.from_airport, COUNT(*) AS number_of_flights FROM flight GROUP BY flight.from_airport ORDER BY number_of_flights ASC NULLS LAST;",atis,group_by +"What is the average cost of a one-way trip for each fare id, sorted in ascending order?","SELECT fare.fare_id, AVG(fare.one_direction_cost) AS average_cost FROM fare GROUP BY fare.fare_id ORDER BY average_cost ASC NULLS LAST;",atis,group_by "How many meals are served in each compartment, sorted by the number of meals in descending order?","SELECT food_service.compartment, COUNT(food_service.meal_number) AS number_of_meals FROM food_service GROUP BY food_service.compartment ORDER BY number_of_meals DESC NULLS LAST;",atis,group_by "What is the average cost of round-trip fares from Los Angeles (LAX) to Chicago (ORD)?","SELECT AVG(fare.round_trip_cost) AS average_cost FROM fare WHERE fare.from_airport = 'LAX' AND fare.to_airport = 'ORD' GROUP BY fare.from_airport, fare.to_airport;",atis,group_by -Which aircraft can carry the highest weight of cargo that any aircraft can carry?,"SELECT aircraft.aircraft_code, aircraft.pay_load FROM aircraft ORDER BY pay_load DESC NULLS LAST LIMIT 1;",atis,order_by -"Which flights to Chicago (ORD) have the longest duration from departure to arrival, sorted in ascending order?","SELECT flight.flight_id, (flight.arrival_time - flight.departure_time) AS duration FROM flight WHERE to_airport = 'ORD' ORDER BY duration ASC NULLS LAST;",atis,order_by -What are the top 2 airlines with the most flights?,"SELECT airline.airline_name, COUNT(flight.flight_id) AS number_of_flights FROM flight JOIN airline ON flight.airline_code = airline.airline_code GROUP BY airline.airline_name ORDER BY number_of_flights DESC NULLS LAST LIMIT 2;",atis,order_by -"Which airports have the shortest minimum connect time, sorted in ascending order?","SELECT airport.airport_name, airport.minimum_connect_time FROM airport ORDER BY airport.minimum_connect_time ASC NULLS LAST;",atis,order_by +Which aircraft code can carry the highest weight of cargo that any aircraft can carry?,"SELECT aircraft.aircraft_code FROM aircraft ORDER BY pay_load DESC NULLS LAST LIMIT 1;",atis,order_by +"Which flight ids to Chicago (ORD) have the longest duration from departure to arrival, sorted in ascending order?","SELECT flight.flight_id, (flight.arrival_time - flight.departure_time) AS duration FROM flight WHERE to_airport = 'ORD' ORDER BY duration ASC NULLS LAST;",atis,order_by +What are the top 2 airlines with the most flights?,"SELECT {airline.airline_name, airline.airline_code}, COUNT(flight.flight_id) AS number_of_flights FROM flight JOIN airline ON flight.airline_code = airline.airline_code GROUP BY {} ORDER BY number_of_flights DESC NULLS LAST LIMIT 2;",atis,order_by +"Which airports have the shortest minimum connect time, sorted in ascending order?","SELECT {airport.airport_name, airport.airport_code}, airport.minimum_connect_time FROM airport ORDER BY airport.minimum_connect_time ASC NULLS LAST;",atis,order_by "What are the aircraft codes for all aircraft with a cruising speed of over 200 mph, sorted in ascending order?",SELECT aircraft.aircraft_code FROM aircraft WHERE aircraft.cruising_speed > 200 ORDER BY aircraft.aircraft_code ASC;,atis,order_by What is the ratio of one-way trip costs to round-trip costs for each fare?,"SELECT fare.fare_id, fare.one_direction_cost::float / NULLIF(fare.round_trip_cost, 0) AS cost_ratio FROM fare ORDER BY cost_ratio;",atis,ratio -What is the ratio of the weight of an aircraft to its maximum payload capacity?,"SELECT aircraft.weight::float / NULLIF(aircraft.pay_load, 0) AS weight_to_payload_ratio FROM aircraft;",atis,ratio +What is the ratio of the weight of all aircrafts to their maximum payload capacity?,"SELECT aircraft.weight::float / NULLIF(aircraft.pay_load, 0) AS weight_to_payload_ratio FROM aircraft;",atis,ratio How does the ratio of the cruising speed to the payload of an aircraft vary across different aircraft manufacturers?,"SELECT aircraft.manufacturer, AVG(CAST(aircraft.cruising_speed AS FLOAT) / NULLIF(aircraft.pay_load, 0)) AS speed_payload_ratio FROM aircraft GROUP BY aircraft.manufacturer ORDER BY speed_payload_ratio DESC NULLS LAST;",atis,ratio What is the proportion of flights with stops out of all flights for each airline code?,"SELECT flight.airline_code, CAST(SUM(CASE WHEN flight.stops > 0 THEN 1 ELSE 0 END) AS FLOAT) / NULLIF(COUNT(*), 0) AS ratio FROM flight GROUP BY flight.airline_code;",atis,ratio What is the ratio of aircraft capacity to its range in miles for each aircraft code?,"SELECT aircraft.aircraft_code, CAST(aircraft.capacity AS FLOAT) / NULLIF(aircraft.range_miles, 0) AS capacity_range_ratio FROM aircraft;",atis,ratio -Which airlines offer flights from LAX to ORD?,SELECT DISTINCT airline.airline_name FROM flight JOIN airline ON flight.airline_code = airline.airline_code WHERE flight.from_airport = 'LAX' AND flight.to_airport = 'ORD';,atis,table_join +Which airlines offer flights from LAX to ORD?,SELECT DISTINCT {airline.airline_name, airline.airline_code} FROM flight JOIN airline ON flight.airline_code = airline.airline_code WHERE flight.from_airport = 'LAX' AND flight.to_airport = 'ORD';,atis,table_join Which flights serve meals in first class? Give me the flight id and meal description.,"SELECT flight.flight_id, food_service.meal_description FROM flight JOIN food_service ON flight.meal_code = food_service.meal_code WHERE LOWER(food_service.compartment) LIKE '%first class%';",atis,table_join -Which airlines offer flights with a stopover in Dallas?,SELECT DISTINCT airline.airline_name FROM flight_stop JOIN airport ON flight_stop.stop_airport = airport.airport_code JOIN flight ON flight_stop.flight_id = flight.flight_id JOIN airline ON flight.airline_code = airline.airline_code WHERE airport.airport_location = 'Dallas';,atis,table_join -Which airlines do not have flights that depart or arrive at JFK?,SELECT DISTINCT a.airline_name FROM public.airline a LEFT JOIN public.flight f ON a.airline_code = f.airline_code AND (f.to_airport = 'JFK' OR f.from_airport = 'JFK') GROUP BY 1 HAVING COUNT(f.flight_id) = 0;,atis,table_join -"Which airlines offer flights from Chicago (ORD) to New York (JFK), and how many stops do they have, sorted by number of stops?","SELECT airline.airline_name, flight.stops FROM flight JOIN airline ON flight.airline_code = airline.airline_code WHERE flight.from_airport = 'ORD' AND flight.to_airport = 'JFK' GROUP BY airline.airline_name, flight.stops ORDER BY flight.stops NULLS LAST;",atis,table_join -What is the total cost of a round-trip fare from New York (JFK) to Los Angeles?,SELECT SUM(fare.round_trip_cost) AS total_round_trip_cost FROM fare WHERE fare.from_airport = 'JFK' AND fare.to_airport = 'LAX';,atis,where +Which airlines offer flights with a stopover in Dallas?,SELECT DISTINCT {airline.airline_name, airline.airline_code} FROM flight_stop JOIN airport ON flight_stop.stop_airport = airport.airport_code JOIN flight ON flight_stop.flight_id = flight.flight_id JOIN airline ON flight.airline_code = airline.airline_code WHERE airport.airport_location = 'Dallas';,atis,table_join +Which airlines do not have flights that depart or arrive at JFK?,SELECT DISTINCT {a.airline_name, a.airline_code} FROM public.airline a LEFT JOIN public.flight f ON a.airline_code = f.airline_code AND (f.to_airport = 'JFK' OR f.from_airport = 'JFK') GROUP BY {} HAVING COUNT(f.flight_id) = 0;,atis,table_join +"Which airlines offer flights from Chicago (ORD) to New York (JFK), and how many stops do they have, sorted by number of stops?","SELECT {airline.airline_name, airline.airline_code}, flight.stops FROM flight JOIN airline ON flight.airline_code = airline.airline_code WHERE flight.from_airport = 'ORD' AND flight.to_airport = 'JFK' GROUP BY {}, flight.stops ORDER BY flight.stops NULLS LAST;",atis,table_join +What is the total cost of all round-trip fares from New York (JFK) to Los Angeles?,SELECT SUM(fare.round_trip_cost) AS total_round_trip_cost FROM fare WHERE fare.from_airport = 'JFK' AND fare.to_airport = 'LAX';,atis,where What is the minimum amount of time required for a connecting flight at JFK Airport?,SELECT minimum_connect_time FROM airport WHERE airport_code = 'JFK';,atis,where How many flights require a round-trip to purchase the fare?,SELECT COUNT(*) FROM fare WHERE round_trip_required = 'Yes';,atis,where -Which flights operate on Mondays and Wednesdays? Give me the relevant flight numbers,SELECT flight.flight_number FROM flight WHERE LOWER(flight.flight_days) LIKE '%mon%' AND LOWER(flight.flight_days) LIKE '%wed%';,atis,where -Which state is Orlando International Airport in?,SELECT state_code FROM airport WHERE airport_name = 'Orlando International Airport';,atis,where +Which flights operate on Mondays and Wednesdays? Give me the relevant flight numbers,SELECT {flight.flight_number, flight.flight_id} FROM flight WHERE LOWER(flight.flight_days) LIKE '%mon%' AND LOWER(flight.flight_days) LIKE '%wed%';,atis,where +Which state code is Orlando International Airport in?,SELECT state_code FROM airport WHERE airport_name = 'Orlando International Airport';,atis,where How many rivers flow through each country?,"SELECT river.country_name, COUNT(DISTINCT river.river_name) AS number_of_rivers FROM river GROUP BY river.country_name ORDER BY number_of_rivers DESC;",geography,group_by What is the total population of each country in the database?,"SELECT city.country_name, SUM(city.population) AS total_population FROM city GROUP BY city.country_name ORDER BY total_population DESC NULLS LAST;",geography,group_by How many lakes are there in each state?,"SELECT lake.state_name, COUNT(lake.lake_name) AS lake_count FROM lake GROUP BY lake.state_name ORDER BY lake_count DESC;",geography,group_by