Chinastark/bird_dataset huggingface dataset:
Database: cs_semester
Note: full name of the students = f_name, l_name; gpa < 3;
Question: For the students with an intelligence of 5, list the full name and courses taken by them who have less than a 3 GPA.
SQL: SELECT student.f_name, student.l_name, course.name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE student.intelligence = 5 AND student.gpa < 3
Database: cs_semester
Note: average capability = AVG(capability); gpa < 2.5;
Question: What is the average capability of students with less than a 2.5 GPA?
SQL: SELECT cast(sum(ra.capability) AS REAL) / count(ra.student_id) FROM ra INNER JOIN student ON ra.student_id = student.student_id WHERE student.gpa < 2.5
Database: cs_semester
Note: full name of the professors = first_name, last_name;
Question: List the full name of the professors who advised students with intelligence 1.
SQL: SELECT prof.first_name, prof.last_name FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE student.intelligence = 1
Database: cs_semester
Note: difference in the average gpa = SUBTraCT(AVG(gpa WHERE MAX(diff)), AVG(gpa where min(diff))); difficulty of the course refers to diff; hardest course refers to MAX(diff); easiest course refers to MIN(diff);
Question: What is the difference in the average GPA of students who took the hardest and easiest courses?
SQL: SELECT avg(student.gpa) FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.diff IN (2, 1) GROUP BY course.diff
Database: cs_semester
Note: full name of students = f_name, l_name; failed refers to grade IS NULL;
Question: Give the full name and capability of students who failed in any courses.
SQL: SELECT student.f_name, student.l_name, ra.capability FROM ra INNER JOIN student ON student.student_id = ra.student_id INNER JOIN registration ON student.student_id = registration.student_id WHERE registration.grade IS NULL OR registration.grade = ''
Database: cs_semester
Note: high salaries refers to salary = 'High';
Question: Of the students with high salaries, how many took the computer vision course?
SQL: SELECT count(ra.student_id) FROM ra INNER JOIN registration ON registration.student_id = ra.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE ra.salary = 'high' AND course.name = 'Computer Vision'
Database: cs_semester
Note: full name of the professor = first_name, last_name; most number of students refers to MAX(COUNT(student_id));
Question: Find the full name and popularity of the professor who advises the most number of students.
SQL: SELECT prof.first_name, prof.last_name, prof.popularity FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id GROUP BY prof.prof_id ORDER BY count(ra.student_id) DESC LIMIT 1
Database: cs_semester
Note: most number of students got an A refers MAX(COUNT(student_id WHERE grade = 'A')); full name = f_name, l_name; got an A refers to grade = 'A';
Question: Please give the name of the course in which most numbers of the students got an A. Also, list the full name of the students who got an A in this course.
SQL: SELECT course.name, student.f_name, student.l_name FROM registration INNER JOIN student ON registration.student_id = student.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE registration.grade = 'A' GROUP BY course.name ORDER BY count(registration.student_id) DESC LIMIT 1
Database: cs_semester
Note: average satisfaction difference = SUBTraCT(AVG(sat where salary = 'high')), (AVG(sat where salary = 'free')); satisfaction refers to sat; no salary refers to salary = 'free';
Question: Calculate the difference between the average satisfaction of the students with high salaries and no salary.
SQL: SELECT avg(registration.sat) - ( SELECT avg(registration.sat) FROM ra INNER JOIN registration ON ra.student_id = registration.student_id WHERE ra.salary = 'free' ) AS diff FROM ra INNER JOIN registration ON ra.student_id = registration.student_id WHERE ra.salary = 'high'
Database: cs_semester
Note: university from which the professor graduated refers to graduate_from; undergraduate students refers to type = 'UG';
Question: Find the university from which the professor who advised most undergraduate students graduated.
SQL: SELECT prof.graduate_from FROM prof INNER JOIN ra ON prof.prof_id = ra.prof_id INNER JOIN student ON ra.student_id = student.student_id WHERE student.type = 'UG' GROUP BY prof.prof_id ORDER BY count(ra.student_id) DESC LIMIT 1
Database: cs_semester
Note: more than average teaching ability refers to teachingability > AVG(teachingability); full_name of the professor = first_name, last_name; email address of the professor refers to email; advises two or more students refers to COUNT(student_id) >= 2;
Question: Among the professors with more than average teaching ability, list the full name and email address of the professors who advise two or more students.
SQL: SELECT prof.first_name, prof.last_name, prof.email FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id WHERE prof.teachingability > ( SELECT avg(teachingability) FROM prof ) GROUP BY prof.prof_id HAVING count(ra.student_id) >= 2
Database: cs_semester
Note: percentage = MULTIPLY(DIVIDE(COUNT(MAX(sat)), (COUNT(student_id))), 1.0); highly satisfied refers to MAX(sat);
Question: What percentage of students are highly satisfied with the Intro to Database 2 course?
SQL: SELECT cast(( SELECT count(*) FROM course WHERE name = 'Intro to Database 2' AND course_id IN ( SELECT course_id FROM registration WHERE sat = ( SELECT max(sat) FROM registration ) ) ) AS REAL) * 100  / count(registration.student_id) FROM registration INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Intro to Database 2'
Database: cs_semester
Note: first name refers of students refers to f_name; last name of students refers to l_name; highest gpa refers to MAX(gpa);
Question: What is the first and last name of students with highest gpa?
SQL: SELECT f_name, l_name FROM student WHERE gpa = ( SELECT max(gpa) FROM student )
Database: cs_semester
Note: highest teachability refers to MAX(teachability); high salary refers to salary = 'high';
Question: Among professors with the highest teachability, how many of their students have high salary?
SQL: SELECT count(ra.student_id) FROM ra INNER JOIN prof ON ra.prof_id = prof.prof_id WHERE ra.salary = 'high' ORDER BY prof.teachingability DESC LIMIT 1
Database: cs_semester
Note: salary range refers to salary;
Question: What is the salary range of the student with an email of grosellg@hku.hk?
SQL: SELECT ra.salary FROM ra INNER JOIN student ON ra.student_id = student.student_id WHERE student.email = 'grosellg@hku.hk'
Database: cs_semester
Note: satisfaction refers to sat;  sat = 4; gpa = 3.8;
Question: Among students that gave satisfaction of value 4 for the course named "Statistical Learning", how many of them have a gpa of 3.8?
SQL: SELECT count(student.student_id) FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Statistical learning' AND registration.sat = 4 AND student.gpa = 3.8
Database: cs_semester
Note: difficulty of 3 refers to diff = 3; intelligence = 2;
Question: Among courses with difficulty of 3, how many students have intellegence level of 2?
SQL: SELECT count(student.student_id) FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.diff = 3 AND student.intelligence = 2
Database: cs_semester
Note: student's first name refers to f_name; student's last name refers to l_name; got a C refers to grade = 'C';
Question: List the student's first and last name that got a C in the course named "Applied Deep Learning".
SQL: SELECT student.f_name, student.l_name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE course.name = 'Applied Deep Learning ' AND registration.grade = 'C'
Database: cs_semester
Note: research postgraduate students refers to type = 'RPG'; name of the course refers to name; satisfaction refers to sat; sat = 1;
Question: Among research postgraduate students, give the name of the course with the student satisfaction value of 1.
SQL: SELECT course.name FROM student INNER JOIN registration ON student.student_id = registration.student_id INNER JOIN course ON registration.course_id = course.course_id WHERE registration.sat = 1 AND student.type = 'RPG'
Database: cs_semester
Note: capability < 3; difference = subtract(count(type = 'UG')), (count(type = 'RPG')); undergraduate students refers to type = 'UG'; research postgraduate students refers to type = 'RPG';
Question: Among the students with a capability below 3, what is the difference of undergraduate students from research postgraduate students?
SQL: SELECT sum(CASE WHEN student.type = 'UG' THEN 1 ELSE 0 END) - sum(CASE WHEN student.type = 'RPG' THEN 1 ELSE 0 END) FROM ra INNER JOIN student ON ra.student_id = student.student_id WHERE ra.capability < 3
Database: computer_student
Note: students refers to advisedby.p_id; advisor refers to p_id_dummy; average number = avg(count(advisedby.p_id));
Question: What is the average number of students for each advisor?
SQL: SELECT cast(count(p_id) AS REAL) / count(DISTINCT p_id_dummy) AS avgnum FROM advisedby GROUP BY p_id_dummy
Database: computer_student
Note: professors refers to taughtby.p_id; course ID 18 refers to taughtby.course_id;
Question: How many professors are teaching course ID 18?
SQL: SELECT count(DISTINCT p_id) FROM taughtby WHERE course_id = 18
Database: computer_student
Note: professional or master/graduate courses refers to courselevel = 'Level_500';
Question: List all the course IDs for professional or master/graduate courses.
SQL: SELECT course_id FROM course WHERE courselevel = 'Level_500'
Database: computer_student
Note: basic or medium undergraduate courses refers to courselevel = 'Level_300'; courses refers to course.course_id;
Question: How many courses are there for basic or medium undergraduate courses?
SQL: SELECT count(course_id) FROM course WHERE courselevel = 'Level_300'
Database: computer_student
Note: ID of all professors refers to person.p_id where professor = 1; not faculty member refers to hasposition = 0; courses refers to taughtby.course_id;
Question: List the ID of all professors who are not faculty member along with the courses taught by him/her.
SQL: SELECT taughtby.p_id, taughtby.course_id FROM person INNER JOIN taughtby ON person.p_id = taughtby.p_id WHERE person.professor = 1 AND person.hasposition <> 0
Database: computer_student
Note: ID of professors refers to taughtby.p_id; high-level or harder undergraduate course refers to courselevel = 'Level_400';
Question: Provide the ID of professors who are teaching high-level or harder undergraduate course.
SQL: SELECT taughtby.p_id FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id WHERE course.courselevel = 'Level_400'
Database: computer_student
Note: courses refers to course_id; advisors refers to p_id_dummy and taughtby.p_id; student with ID 376 refers to advisedby.p_id = 376;
Question: What are the courses taught by the advisors who gave advice to student with ID 376?
SQL: SELECT taughtby.course_id FROM advisedby INNER JOIN person ON advisedby.p_id = person.p_id INNER JOIN taughtby ON person.p_id = taughtby.p_id WHERE advisedby.p_id = 141
Database: computer_student
Note: advisors refers to p_id_dummy; students in Year 3 of the program refers to yearsinprogram = 'Year_3';
Question: Name the advisors for students in Year 3 of the program.
SQL: SELECT advisedby.p_id FROM advisedby INNER JOIN person ON advisedby.p_id = person.p_id WHERE person.yearsinprogram = 'Year_3'
Database: computer_student
Note: professor ID 297 refers to taughtby.p_id = 297;
Question: Which level of courses is taught by professor ID 297?
SQL: SELECT course.courselevel FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id WHERE taughtby.p_id = 297
Database: computer_student
Note: course 165 refers to course_id = 165; professors refers to taughtby.p_id;
Question: What level is course 165? List the professors who teach the course.
SQL: SELECT course.courselevel, taughtby.p_id FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id WHERE taughtby.course_id = 165
Database: computer_student
Note: advisor with ID 5 refers to p_id_dummy = 5;
Question: List the ID and years in program for students taught by advisor with ID 5.
SQL: SELECT advisedby.p_id, person.yearsinprogram FROM advisedby INNER JOIN person ON advisedby.p_id = person.p_id WHERE advisedby.p_id_dummy = 5
Database: computer_student
Note: professors who are faculty employees refers to professor = 1; faculty employees refers to hasposition = 'Faculty_eme';
Question: State the courses and level of courses by professors who are faculty employees.
SQL: SELECT course.course_id, course.courselevel FROM taughtby INNER JOIN person ON taughtby.p_id = person.p_id INNER JOIN course ON course.course_id = taughtby.course_id WHERE person.hasposition = 'Faculty_eme'
Database: computer_student
Note: ID of advisor refers to p_id_dummy; student ID 80 refers to advisedby.p_id = 80; level of courses refers to courselevel;
Question: Find the ID of advisor of student ID 80 and state the level of courses taught by him/her.
SQL: SELECT advisedby.p_id_dummy, course.courselevel FROM advisedby INNER JOIN course ON advisedby.p_id = course.course_id INNER JOIN taughtby ON course.course_id = taughtby.course_id WHERE advisedby.p_id = 80
Database: computer_student
Note: harder undergraduate course refers to courselevel = 'Level_400'; master/graduate courses refers to courselevel = 'Level_500'; ID of professors refers to taughtby.p_id;
Question: Provide the ID of professors who teach in both harder undergraduate course and master/graduate courses.
SQL: SELECT DISTINCT taughtby.p_id FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id WHERE course.courselevel = 'Level_400' OR course.courselevel = 'Level_500'
Database: computer_student
Note: professors refers to p_id_dummy; 12th years of program refers to yearsinprogram = 'Year_12';
Question: Who are the professors who gave advice to students in the 12th years of program?
SQL: SELECT advisedby.p_id_dummy FROM advisedby INNER JOIN person ON advisedby.p_id = person.p_id WHERE person.yearsinprogram = 'Year_12'
Database: computer_student
Note: courses refers taughtby.course_id; most number of professors  refers to max(count(taughtby.p_id)); level of the course refers to courselevel;
Question: Which are the courses with the most number of professors? State the course ID and the level of the course.
SQL: SELECT course.course_id, course.courselevel FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id GROUP BY course.course_id, course.courselevel ORDER BY count(course.course_id) DESC LIMIT 1
Database: computer_student
Note: basic and medium undergraduate courses refers to courselevel = 'Level_300' and courses refers to course.course_id;
Question: How many basic and medium undergraduate courses are there?
SQL: SELECT count(*) FROM course WHERE courselevel = 'Level_300'
Database: computer_student
Note: people refers to taughtby.p_id; course no.11 refers to course_id = 11;
Question: How many people teaches course no.11?
SQL: SELECT count(*) FROM taughtby WHERE course_id = 11
Database: computer_student
Note: teachers refers to taughtby.p_id; course no.16 refers to course_id = 16; course no.18 refers to course_id = 18;
Question: Which course has more teachers, course no.16 or course no.18?
SQL: SELECT course_id FROM taughtby WHERE course_id = 11 OR course_id = 18 GROUP BY course_id ORDER BY count(course_id) DESC LIMIT 1
Database: computer_student
Note: teachers refers to professor = 1; faculty employees refers to hasposition = 'Faculty_eme';
Question: How many teachers are faculty employees?
SQL: SELECT count(*) FROM person WHERE hasposition = 'Faculty_eme'
Database: computer_student
Note: teachers refers to p_id_dummy; have advised more than 4 others refers to count(advisedby.p_id) > 4;
Question: Please list the IDs of the teachers who have advised more than 4 others to teach.
SQL: SELECT p_id_dummy FROM advisedby GROUP BY p_id_dummy HAVING count(p_id_dummy) > 4
Database: computer_student
Note: basic or medium undergraduate courses refers to courselevel = 'Level_300'; professor refers to professor = 1;
Question: How many basic or medium undergraduate courses are taught by a professor?
SQL: SELECT count(*) FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id INNER JOIN person ON person.p_id = taughtby.p_id WHERE course.courselevel = 'Level_300' AND person.professor = 1
Database: computer_student
Note: faculty employees refers to hasposition = 'Faculty_eme'; basic or medium undergraduate course refers to courselevel = 'Level_300';
Question: Please list the IDs of all the faculty employees who teaches a basic or medium undergraduate course.
SQL: SELECT taughtby.p_id FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id INNER JOIN person ON person.p_id = taughtby.p_id WHERE course.courselevel = 'Level_300' AND person.hasposition = 'Faculty_eme'
Database: computer_student
Note: teacher refers to taughtby.p_id; course no.9 refers to taughtby.course_id = 9; faculty member refers to hasposition ! = 0;
Question: Is the teacher who teaches course no.9 a faculty member?
SQL: SELECT person.hasposition FROM taughtby INNER JOIN person ON taughtby.p_id = person.p_id WHERE taughtby.course_id = 9
Database: computer_student
Note: levels of the all courses refers to courselevel; teacher no.79 refers to taughtby.p_id = 79;
Question: Please list the levels of the all courses taught by teacher no.79.
SQL: SELECT course.courselevel FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id WHERE taughtby.p_id = 79
Database: computer_student
Note: IDs of the advisors refers to p_id_dummy; in the 5th year of their program refers to yearsinprogram = 'Year_5';
Question: Please list the IDs of the advisors of the students who are in the 5th year of their program.
SQL: SELECT advisedby.p_id_dummy FROM advisedby INNER JOIN person ON advisedby.p_id = person.p_id WHERE person.yearsinprogram = 'Year_5'
Database: computer_student
Note: students refers to advisedby.p_id; professor refers to p_id_dummy and taughtby.p_id and professor = 1; basic or medium undergraduate courses refers to courselevel = 'Level_300';
Question: How many students are advised to teach by a professor teaching basic or medium undergraduate courses?
SQL: SELECT count(DISTINCT advisedby.p_id) FROM person INNER JOIN taughtby ON person.p_id = taughtby.p_id INNER JOIN course ON course.course_id = taughtby.course_id INNER JOIN advisedby ON advisedby.p_id = person.p_id WHERE person.professor = 1 AND course.courselevel = 'Level_300'
Database: computer_student
Note: courses that are basic or medium undergraduate courses refers to courselevel = 'Level_300'; faculty member refers to hasposition ! = 0;
Question: Among the courses that are basic or medium undergraduate courses, how many of them are taught by a faculty member?
SQL: SELECT count(*) FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id INNER JOIN person ON taughtby.p_id = person.p_id WHERE person.professor = 1 AND course.courselevel = 'Level_300'
Database: computer_student
Note: professor refers to p_id_dummy and professor = 1; student no.6 refers to advisedby.p_id = 6; IDs of the courses refers to taughtby.course_id;
Question: For the professor who advised student no.6, please list the IDs of the courses he or she teaches.
SQL: SELECT course.course_id FROM taughtby INNER JOIN course ON taughtby.course_id = course.course_id INNER JOIN advisedby ON advisedby.p_id = taughtby.p_id WHERE taughtby.p_id = 9
Database: computer_student
Note: level of the course refers to courselevel; course with most number of teachers refers to course_id = max(count(taughtby.p_id));
Question: What is the level of the course with the most number of teachers?
SQL: SELECT course.courselevel FROM course INNER JOIN taughtby ON course.course_id = taughtby.course_id GROUP BY taughtby.course_id ORDER BY count(taughtby.p_id) DESC LIMIT 1
Database: computer_student
Note: IDs of the professors refers to taughtby.p_id and professor = 1; teaches more than 3 courses  refers to count(course_id) > 3;
Question: Please list the IDs of the professors that teaches more than 3 courses.
SQL: SELECT taughtby.p_id FROM taughtby INNER JOIN person ON taughtby.p_id = person.p_id WHERE person.professor = 1 GROUP BY taughtby.p_id HAVING count(DISTINCT taughtby.course_id) > 3
Database: computer_student
Note: IDs of the professors refers to taughtby.p_id and professor = 1; teaches the most courses refers to max(count(course_id));
Question: Please list the IDs of the top 3 professors that teaches the most courses.
SQL: SELECT taughtby.p_id FROM taughtby INNER JOIN person ON taughtby.p_id = person.p_id WHERE person.professor = 1 GROUP BY taughtby.p_id ORDER BY count(*) DESC LIMIT 3
Database: computer_student
Note: 3rd year of their program refers to yearsinprogram = 'Year_3'; professors refers to p_id_dummy;
Question: In total, all the students in the 3rd year of their program are advised by how many professors?
SQL: SELECT count(DISTINCT advisedby.p_id_dummy) FROM advisedby INNER JOIN person ON advisedby.p_id = person.p_id WHERE person.yearsinprogram = 'Year_3'
Database: computer_student
Note: professor refers to professor = 1; average number of courses = divide(count(taughtby.course_id), count(taughtby.p_id) where professor = 1 );
Question: What is the average number of courses taught by a professor?
SQL: SELECT cast(count(taughtby.course_id) AS REAL) / count(DISTINCT person.p_id) AS num FROM taughtby INNER JOIN person ON taughtby.p_id = person.p_id WHERE person.professor = 1
Database: computer_student
Note: professors refers to professor = 1; students refers to student = 1; ratio = divide(count(person.p_id) when professor = 1, count(person.p_id) when student = 1);
Question: What is the ratio of professors and students?
SQL: SELECT cast(sum(CASE  WHEN professor = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / sum(CASE  WHEN student = 1 THEN 1 ELSE 0 END) AS per FROM person
Database: computer_student
Note: high-level undergraduate course refers to courselevel = 'Level_400'; percentage = divide(count(course.course_id) when courselevel = 'Level_400', count(course.course_id)) * 100%;
Question: Calculate the percentage of high-level undergraduate course.
SQL: SELECT cast(sum(CASE  WHEN courselevel = 'Level_400' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) AS per FROM course
Database: computer_student
Note: person IDs refers to taughtby.p_id; course ID of 18  refers to taughtby.course_id = 18;
Question: List down all the person IDs who taught course ID of 18.
SQL: SELECT p_id FROM taughtby WHERE course_id = 18
Database: computer_student
Note: position status refers to hasposition; IDs of professor refers to p_id_dummy; student ID "303" refers to advisedby.p_id = 303;
Question: Provide the position status and IDs of professor who advised student ID "303".
SQL: SELECT person.hasposition, advisedby.p_id_dummy FROM advisedby INNER JOIN person ON advisedby.p_id_dummy = person.p_id WHERE advisedby.p_id = 303
Database: computer_student
Note: person IDs refers to person.p_id; affiliated professors in faculty refers to professor = 1 and hasposition = 'Faculty_aff';
Question: List the person IDs and course levels of the affiliated professors in faculty.
SQL: SELECT person.p_id, course.courselevel FROM person INNER JOIN taughtby ON person.p_id = taughtby.p_id INNER JOIN course ON course.course_id = taughtby.course_id WHERE person.hasposition = 'Faculty_aff'