Skip to content

Commit

Permalink
- L31: added multiple columns
Browse files Browse the repository at this point in the history
- L56: modified SQL to result in non-empty df
- L63: modified query to fit group_by category
  • Loading branch information
wendy-aw authored and wongjingping committed Aug 17, 2023
1 parent 869090e commit 73b6623
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions data/questions_gen.csv
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ How many courses are offered in each semester id?,"SELECT course_offering.semest
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 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?,"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 average clarity score for each instructor who taught a course?,"SELECT {instructor.name, instructor.instructor_id}, AVG(comment_instructor.score) as average_score FROM comment_instructor JOIN instructor ON comment_instructor.instructor_id = instructor.instructor_id GROUP BY {} 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
Expand All @@ -53,14 +53,14 @@ What is the total cost of round-trip fares for each airline code?,"SELECT fare.f
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
"What is the average cost of round-trip fares from Los Angeles (LAX) to Chicago (ORD) for each airline, sorted in descending order by average cost?","SELECT fare.fare_airline, AVG(fare.round_trip_cost) AS average_cost FROM fare WHERE fare.from_airport = 'LAX' AND fare.to_airport = 'ORD' GROUP BY fare.fare_airline ORDER BY average_cost DESC NULLS LAST;",atis,group_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 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
What is the ratio of the maximum range to the maximum payload capacity for all aircraft?,"SELECT aircraft.range_miles::float / NULLIF(aircraft.pay_load, 0) AS range_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
Expand Down

0 comments on commit 73b6623

Please sign in to comment.