input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] Please write me a SQL statement that answers the following question: How many of the professors are female? [/INST]
SELECT COUNT(prof_id) FROM prof WHERE gender = 'Female';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the most difficult course? [/INST]
SELECT name FROM course WHERE diff = ( SELECT MAX(diff) FROM course );
[INST] Here is a database schema: student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among the students with a gpa of 3.1 to 3.7, how many of them are undergraduate students? [/INST]
SELECT COUNT(student_id) FROM student WHERE gpa BETWEEN 3.1 AND 3.7 AND type = 'UG';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] Please write me a SQL statement that answers the following question: What is the credit of the course named "Computer Vision"? [/INST]
SELECT credit FROM course WHERE name = 'Computer Vision';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Give the student's ID of students with 2.5 GPA and enrolled in C for Programmers. [/INST]
SELECT T2.student_id FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'C for Programmers' AND T1.gpa = 2.5;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Give the student's last name that gave the highest student satisfaction for the course "Intro to Database 2". [/INST]
SELECT T1.l_name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Intro to Database 2' ORDER BY T2.sat DESC LIMIT 1;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among the students with high salary, what is total number of students with a GPA higher than 3? [/INST]
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'high' AND T2.gpa > 3;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among undergraduate students, list the name of the course with the highest student satisfaction. [/INST]
SELECT T3.name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.type = 'UG' ORDER BY T2.sat DESC LIMIT 1;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: List the capability of research postgraduate students with an intellegence level of 4 and above. [/INST]
SELECT T1.capability FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T2.type = 'RPG' AND T2.intelligence >= 4;
[INST] Here is a database schema: registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: In students with a grade of B, how many of them have an intellegence level of 3? [/INST]
SELECT COUNT(T1.student_id) FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.grade = 'B' AND T2.intelligence = 3;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: What is the difficulty of the course in which a student with level of intellengence of 5 got an A grade? [/INST]
SELECT T3.diff FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T2.grade = 'A' AND T1.intelligence = 5;
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] Please write me a SQL statement that answers the following question: Among professors with the highest popularity, how many of their students have research capability of 5? [/INST]
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T1.capability = 5 ORDER BY T2.popularity DESC LIMIT 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] Please write me a SQL statement that answers the following question: List the course's name where students acquired a grade of D. [/INST]
SELECT T1.name FROM course AS T1 INNER JOIN registration AS T2 ON T1.course_id = T2.course_id WHERE T2.grade = 'D';
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: What is the capability on research of the student named Alvera McQuillin? [/INST]
SELECT T2.capability FROM student AS T1 INNER JOIN RA AS T2 ON T1.student_id = T2.student_id WHERE T1.f_name = 'Alvera' AND T1.l_name = 'McQuillin';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Of courses with 3 credit, how many students have GPA of 3.2? [/INST]
SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.credit = 3 AND T1.gpa = 3.2;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among students with low salary, how many of them have a gpa of 3.5? [/INST]
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T2.gpa = 3.5 AND T1.salary = 'low';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: List the student's email with grade of B in a course with difficulty greater than the 80% of average difficulty of all courses. [/INST]
SELECT T2.email FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T1.course_id = T3.course_id WHERE T1.grade = 'B' GROUP BY T3.diff HAVING T3.diff > AVG(T3.diff) * 0.8;
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] Please write me a SQL statement that answers the following question: Among the professors with a teachability of 3 and below, what is the percentage of their student advisees with a low salary? [/INST]
SELECT CAST(SUM(CASE WHEN T1.salary = 'low' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.salary) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.teachingability < 3;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] Please write me a SQL statement that answers the following question: Find the most important and most difficult courses. [/INST]
SELECT name FROM course WHERE credit = ( SELECT MAX(credit) FROM course ) AND diff = ( SELECT MAX(diff) FROM course );
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] Please write me a SQL statement that answers the following question: What is the average teaching ability of the most popular professors? [/INST]
SELECT CAST(SUM(teachingability) AS REAL) / COUNT(prof_id) FROM prof WHERE popularity = ( SELECT MAX(popularity) FROM prof );
[INST] Here is a database schema: registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average satisfaction of the good students with their courses. [/INST]
SELECT CAST(SUM(sat) AS REAL) / COUNT(course_id) FROM registration WHERE grade = 'B';
[INST] Here is a database schema: student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among the students with less than four intelligence, list the full name and phone number of students with a greater than 3 GPA. [/INST]
SELECT f_name, l_name, phone_number FROM student WHERE gpa > 3 AND intelligence < 4;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Name the students with above-average capability. [/INST]
SELECT T1.f_name, T1.l_name FROM student AS T1 INNER JOIN RA AS T2 ON T1.student_id = T2.student_id WHERE T2.capability > ( SELECT AVG(capability) FROM RA );
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following 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. [/INST]
SELECT T1.f_name, T1.l_name, T3.name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.intelligence = 5 AND T1.gpa < 3;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: What is the average capability of students with less than a 2.5 GPA? [/INST]
SELECT CAST(SUM(T1.capability) AS REAL) / COUNT(T1.student_id) FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T2.gpa < 2.5;
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: List the full name of the professors who advised students with intelligence 1. [/INST]
SELECT T1.first_name, T1.last_name FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T2.student_id = T3.student_id WHERE T3.intelligence = 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: What is the difference in the average GPA of students who took the hardest and easiest courses? [/INST]
SELECT AVG(T1.gpa) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.diff IN (2, 1) GROUP BY T3.diff;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Give the full name and capability of students who failed in any courses. [/INST]
SELECT T2.f_name, T2.l_name, T1.capability FROM RA AS T1 INNER JOIN student AS T2 ON T2.student_id = T1.student_id INNER JOIN registration AS T3 ON T2.student_id = T3.student_id WHERE T3.grade IS NULL OR T3.grade = '';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] Please write me a SQL statement that answers the following question: Of the students with high salaries, how many took the computer vision course? [/INST]
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN registration AS T2 ON T2.student_id = T1.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.salary = 'high' AND T3.name = 'Computer Vision';
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] Please write me a SQL statement that answers the following question: Find the full name and popularity of the professor who advises the most number of students. [/INST]
SELECT T1.first_name, T1.last_name, T1.popularity FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id GROUP BY T1.prof_id ORDER BY COUNT(T2.student_id) DESC LIMIT 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following 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. [/INST]
SELECT T3.name, T2.f_name, T2.l_name FROM registration AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T1.course_id = T3.course_id WHERE T1.grade = 'A' GROUP BY T3.name ORDER BY COUNT(T1.student_id) DESC LIMIT 1;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the difference between the average satisfaction of the students with high salaries and no salary. [/INST]
SELECT AVG(T2.sat) - ( SELECT AVG(T2.sat) FROM RA AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'free' ) AS diff FROM RA AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id WHERE T1.salary = 'high';
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Find the university from which the professor who advised most undergraduate students graduated. [/INST]
SELECT T1.graduate_from FROM prof AS T1 INNER JOIN RA AS T2 ON T1.prof_id = T2.prof_id INNER JOIN student AS T3 ON T2.student_id = T3.student_id WHERE T3.type = 'UG' GROUP BY T1.prof_id ORDER BY COUNT(T2.student_id) DESC LIMIT 1;
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] Please write me a SQL statement that answers the following 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. [/INST]
SELECT T2.first_name, T2.last_name, T2.email FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T2.teachingability > ( SELECT AVG(teachingability) FROM prof ) GROUP BY T2.prof_id HAVING COUNT(T1.student_id) >= 2;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] Please write me a SQL statement that answers the following question: What percentage of students are highly satisfied with the Intro to Database 2 course? [/INST]
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(T1.student_id) FROM registration AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.name = 'Intro to Database 2';
[INST] Here is a database schema: student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: What is the first and last name of students with highest gpa? [/INST]
SELECT f_name, l_name FROM student WHERE gpa = ( SELECT MAX(gpa) FROM student );
[INST] Here is a database schema: prof : prof_id [ INTEGER ] primary_key gender [ TEXT ] first_name [ TEXT ] last_name [ TEXT ] email [ TEXT ] popularity [ INTEGER ] teachingability [ INTEGER ] graduate_from [ TEXT ] RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] Please write me a SQL statement that answers the following question: Among professors with the highest teachability, how many of their students have high salary? [/INST]
SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T1.salary = 'high' ORDER BY T2.teachingability DESC LIMIT 1;
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: What is the salary range of the student with an email of grosellg@hku.hk? [/INST]
SELECT T1.salary FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T2.email = 'grosellg@hku.hk';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following 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? [/INST]
SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Statistical learning' AND T2.sat = 4 AND T1.gpa = 3.8;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among courses with difficulty of 3, how many students have intellegence level of 2? [/INST]
SELECT COUNT(T1.student_id) FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.diff = 3 AND T1.intelligence = 2;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: List the student's first and last name that got a C in the course named "Applied Deep Learning". [/INST]
SELECT T1.f_name, T1.l_name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.name = 'Applied Deep Learning ' AND T2.grade = 'C';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key name [ TEXT ] credit [ INTEGER ] diff [ INTEGER ] registration : course_id [ INTEGER ] registration.course_id = course.course_id student_id [ INTEGER ] registration.student_id = student.student_id grade [ TEXT ] sat [ INTEGER ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among research postgraduate students, give the name of the course with the student satisfaction value of 1. [/INST]
SELECT T3.name FROM student AS T1 INNER JOIN registration AS T2 ON T1.student_id = T2.student_id INNER JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T2.sat = 1 AND T1.type = 'RPG';
[INST] Here is a database schema: RA : student_id [ INTEGER ] RA.student_id = student.student_id capability [ INTEGER ] prof_id [ INTEGER ] RA.prof_id = prof.prof_id salary [ TEXT ] student : student_id [ INTEGER ] primary_key f_name [ TEXT ] l_name [ TEXT ] phone_number [ TEXT ] email [ TEXT ] intelligence [ INTEGER ] gpa [ REAL ] type [ TEXT ] Please write me a SQL statement that answers the following question: Among the students with a capability below 3, what is the difference of undergraduate students from research postgraduate students? [/INST]
SELECT SUM(CASE WHEN T2.type = 'UG' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.type = 'RPG' THEN 1 ELSE 0 END) FROM RA AS T1 INNER JOIN student AS T2 ON T1.student_id = T2.student_id WHERE T1.capability < 3;
[INST] Here is a database schema: advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: What is the average number of students for each advisor? [/INST]
SELECT CAST(COUNT(p_id) AS REAL) / COUNT(DISTINCT p_id_dummy) AS avgnum FROM advisedBy GROUP BY p_id_dummy;
[INST] Here is a database schema: taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many professors are teaching course ID 18? [/INST]
SELECT COUNT(DISTINCT p_id) FROM taughtBy WHERE course_id = 18;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] Please write me a SQL statement that answers the following question: List all the course IDs for professional or master/graduate courses. [/INST]
SELECT course_id FROM course WHERE courseLevel = 'Level_500';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] Please write me a SQL statement that answers the following question: How many courses are there for basic or medium undergraduate courses? [/INST]
SELECT COUNT(course_id) FROM course WHERE courseLevel = 'Level_300';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: List the ID of all professors who are not faculty member along with the courses taught by him/her. [/INST]
SELECT T2.p_id, T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition <> 0;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Provide the ID of professors who are teaching high-level or harder undergraduate course. [/INST]
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: What are the courses taught by the advisors who gave advice to student with ID 376? [/INST]
SELECT T3.course_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id INNER JOIN taughtBy AS T3 ON T2.p_id = T3.p_id WHERE T1.p_id = 141;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Name the advisors for students in Year 3 of the program. [/INST]
SELECT T1.p_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_3';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which level of courses is taught by professor ID 297? [/INST]
SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 297;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: What level is course 165? List the professors who teach the course. [/INST]
SELECT T1.courseLevel, T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.course_id = 165;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: List the ID and years in program for students taught by advisor with ID 5. [/INST]
SELECT T1.p_id, T2.yearsInProgram FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.p_id_dummy = 5;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: State the courses and level of courses by professors who are faculty employees. [/INST]
SELECT T3.course_id, T3.courseLevel FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T1.course_id WHERE T2.hasPosition = 'Faculty_eme';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Find the ID of advisor of student ID 80 and state the level of courses taught by him/her. [/INST]
SELECT T1.p_id_dummy, T2.courseLevel FROM advisedBy AS T1 INNER JOIN course AS T2 ON T1.p_id = T2.course_id INNER JOIN taughtBy AS T3 ON T2.course_id = T3.course_id WHERE T1.p_id = 80;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Provide the ID of professors who teach in both harder undergraduate course and master/graduate courses. [/INST]
SELECT DISTINCT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_400' OR T1.courseLevel = 'Level_500';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Who are the professors who gave advice to students in the 12th years of program? [/INST]
SELECT T1.p_id_dummy FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_12';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which are the courses with the most number of professors? State the course ID and the level of the course. [/INST]
SELECT T1.course_id, T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_id, T1.courseLevel ORDER BY COUNT(T1.course_id) DESC LIMIT 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] Please write me a SQL statement that answers the following question: How many basic and medium undergraduate courses are there? [/INST]
SELECT COUNT(*) FROM course WHERE courseLevel = 'Level_300';
[INST] Here is a database schema: taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many people teaches course no.11? [/INST]
SELECT COUNT(*) FROM taughtBy WHERE course_id = 11;
[INST] Here is a database schema: taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which course has more teachers, course no.16 or course no.18? [/INST]
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;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] Please write me a SQL statement that answers the following question: How many teachers are faculty employees? [/INST]
SELECT COUNT(*) FROM person WHERE hasPosition = 'Faculty_eme';
[INST] Here is a database schema: advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Please list the IDs of the teachers who have advised more than 4 others to teach. [/INST]
SELECT p_id_dummy FROM advisedBy GROUP BY p_id_dummy HAVING COUNT(p_id_dummy) > 4;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many basic or medium undergraduate courses are taught by a professor? [/INST]
SELECT COUNT(*) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id INNER JOIN person AS T3 ON T3.p_id = T2.p_id WHERE T1.courseLevel = 'Level_300' AND T3.professor = 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Please list the IDs of all the faculty employees who teaches a basic or medium undergraduate course. [/INST]
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id INNER JOIN person AS T3 ON T3.p_id = T2.p_id WHERE T1.courseLevel = 'Level_300' AND T3.hasPosition = 'Faculty_eme';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Is the teacher who teaches course no.9 a faculty member? [/INST]
SELECT T2.hasPosition FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.course_id = 9;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Please list the levels of the all courses taught by teacher no.79. [/INST]
SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 79;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Please list the IDs of the advisors of the students who are in the 5th year of their program. [/INST]
SELECT T1.p_id_dummy FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_5';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: How many students are advised to teach by a professor teaching basic or medium undergraduate courses? [/INST]
SELECT COUNT(DISTINCT T4.p_id) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id INNER JOIN advisedBy AS T4 ON T4.p_id = T1.p_id WHERE T1.professor = 1 AND T3.courseLevel = 'Level_300';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Among the courses that are basic or medium undergraduate courses, how many of them are taught by a faculty member? [/INST]
SELECT COUNT(*) FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id INNER JOIN person AS T3 ON T2.p_id = T3.p_id WHERE T3.professor = 1 AND T1.courseLevel = 'Level_300';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: For the professor who advised student no.6, please list the IDs of the courses he or she teaches. [/INST]
SELECT T2.course_id FROM taughtBy AS T1 INNER JOIN course AS T2 ON T1.course_id = T2.course_id INNER JOIN advisedBy AS T3 ON T3.p_id = T1.p_id WHERE T1.p_id = 9;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: What is the level of the course with the most number of teachers? [/INST]
SELECT T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id ORDER BY COUNT(T2.p_id) DESC LIMIT 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Please list the IDs of the professors that teaches more than 3 courses. [/INST]
SELECT T1.p_id FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.professor = 1 GROUP BY T1.p_id HAVING COUNT(DISTINCT T1.course_id) > 3;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Please list the IDs of the top 3 professors that teaches the most courses. [/INST]
SELECT T1.p_id FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.professor = 1 GROUP BY T1.p_id ORDER BY COUNT(*) DESC LIMIT 3;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: In total, all the students in the 3rd year of their program are advised by how many professors? [/INST]
SELECT COUNT(DISTINCT T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_3';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: What is the average number of courses taught by a professor? [/INST]
SELECT CAST(COUNT(T1.course_id) AS REAL) / COUNT(DISTINCT T2.p_id) AS num FROM taughtBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.professor = 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] Please write me a SQL statement that answers the following question: What is the ratio of professors and students? [/INST]
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;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the percentage of high-level undergraduate course. [/INST]
SELECT CAST(SUM(CASE WHEN courseLevel = 'Level_400' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS per FROM course;
[INST] Here is a database schema: taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: List down all the person IDs who taught course ID of 18. [/INST]
SELECT p_id FROM taughtBy WHERE course_id = 18;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Provide the position status and IDs of professor who advised student ID "303". [/INST]
SELECT T2.hasPosition, T1.p_id_dummy FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id_dummy = T2.p_id WHERE T1.p_id = 303;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: List the person IDs and course levels of the affiliated professors in faculty. [/INST]
SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_aff';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Describe the year in program and in phase status for the student with most number in advisor. [/INST]
SELECT T2.yearsInProgram, T2.inPhase FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id GROUP BY T1.p_id ORDER BY COUNT(*) DESC LIMIT 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: List down the advised student IDs and IDs of employing professor in faculty. [/INST]
SELECT T1.p_id, T2.p_id FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id_dummy = T2.p_id WHERE hasPosition = 'Faculty_eme';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: List the course IDs and levels of person IDs from 40 to 50. [/INST]
SELECT T1.course_id, T1.courseLevel FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id BETWEEN 40 AND 50;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Describe the course level and list of person IDs who taught course ID of 147. [/INST]
SELECT T1.courseLevel, T1.course_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T2.p_id = 141;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Mention the person ID of faculty professor who taught course ID 104 and the course level. [/INST]
SELECT T1.p_id, T3.courseLevel FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T3.course_id = 104 AND T1.hasPosition <> 0;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Find the professor ID and position in faculty who taught high-level undergraduate course of less than 10 in ID. [/INST]
SELECT T1.p_id, T1.hasPosition FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T3.courseLevel = 'Level_400' AND T2.course_id < 10;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: List the professor ID who taught the course ID from 121 to 130 of basic undergraduate courses. [/INST]
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_300' AND T1.course_id > 121 AND T1.course_id < 130;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: List the advisor IDs for students with eighth year of program and position status in faculty of those professors. [/INST]
SELECT T1.p_id_dummy, T2.hasPosition FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_8';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: List any five of course IDs with professor IDs who taught master courses. [/INST]
SELECT T1.course_id, T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500' LIMIT 5;
[INST] Here is a database schema: advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: How many students are under advisor 415? [/INST]
SELECT COUNT(*) FROM advisedBy WHERE p_id_dummy = 415;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] Please write me a SQL statement that answers the following question: How many professional or master/graduate courses are there? [/INST]
SELECT COUNT(*) FROM course WHERE courseLevel = 'Level_500';
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] Please write me a SQL statement that answers the following question: How many non-faculty members are not undergoing the phase of qualifications? [/INST]
SELECT COUNT(*) FROM person WHERE hasPosition = 0 AND inPhase = 0;
[INST] Here is a database schema: taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which professor taught the least amount of courses? [/INST]
SELECT p_id FROM taughtBy GROUP BY p_id ORDER BY COUNT(course_id) ASC LIMIT 1;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: Among the students being advised by Advisor 5, how many students are in the 5th year? [/INST]
SELECT COUNT(*) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T1.p_id_dummy = 5 AND T2.student = 1 AND T2.yearsInProgram = 'Year_5';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Which professor teaches the highest number of professional or master/graduate courses? [/INST]
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500' GROUP BY T2.p_id ORDER BY COUNT(T2.course_id) DESC LIMIT 1;
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Among the faculty affiliated professor, how many professors teaches professional or master/undergraduate courses? [/INST]
SELECT COUNT(*) FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id INNER JOIN course AS T3 ON T3.course_id = T2.course_id WHERE T1.hasPosition = 'Faculty_aff' AND T1.professor = 1 AND T3.courseLevel = 'Level_500';
[INST] Here is a database schema: course : course_id [ INTEGER ] primary_key courseLevel [ TEXT ] taughtBy : course_id [ INTEGER ] taughtBy.course_id = course.course_id p_id [ INTEGER ] taughtBy.p_id = person.p_id Please write me a SQL statement that answers the following question: Who are the top 5 professors who teaches the highest number of professional or master/undergraduate courses? [/INST]
SELECT T2.p_id FROM course AS T1 INNER JOIN taughtBy AS T2 ON T1.course_id = T2.course_id WHERE T1.courseLevel = 'Level_500' GROUP BY T2.p_id ORDER BY COUNT(T2.p_id) DESC LIMIT 5;
[INST] Here is a database schema: person : p_id [ INTEGER ] primary_key professor [ INTEGER ] student [ INTEGER ] hasPosition [ TEXT ] inPhase [ TEXT ] yearsInProgram [ TEXT ] advisedBy : p_id [ INTEGER ] advisedBy.p_id = person.p_id p_id_dummy [ INTEGER ] advisedBy.p_id_dummy = person.p_id Please write me a SQL statement that answers the following question: How many advisors are in charge of advising all the students in 1st year? [/INST]
SELECT COUNT(T1.p_id_dummy) FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_1' AND T2.student = 1;