human
Schema:
class (CLASS_CODE, CRS_CODE, CLASS_SECTION, CLASS_TIME, CLASS_ROOM, PROF_NUM)
course (CRS_CODE, DEPT_CODE, CRS_DESCRIPTION, CRS_CREDIT)
department (DEPT_CODE, DEPT_NAME, SCHOOL_CODE, EMP_NUM, DEPT_ADDRESS, DEPT_EXTENSION)
employee (EMP_NUM, EMP_LNAME, EMP_FNAME, EMP_INITIAL, EMP_JOBCODE, EMP_HIREDATE, EMP_DOB)
enroll (CLASS_CODE, STU_NUM, ENROLL_GRADE)
professor (EMP_NUM, DEPT_CODE, PROF_OFFICE, PROF_EXTENSION, PROF_HIGH_DEGREE)
student (STU_NUM, STU_LNAME, STU_FNAME, STU_INIT, STU_DOB, STU_HRS, STU_CLASS, STU_GPA, STU_TRANSFER, DEPT_CODE, STU_PHONE, PROF_NUM)
Please answer with SQL.
assistant
Sure, I understand.
human
Find names of all students who took some course and the course description.
assistant
SELECT T1.stu_fname , T1.stu_lname , T4.crs_description FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code JOIN course AS T4 ON T3.crs_code = T4.crs_code
human
Find the description and credit for the course QM-261?
assistant
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261'
human
Find the first names of all instructors who have taught some course and the course code.
assistant
SELECT T2.emp_fname , T1.crs_code FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num
human
How many different locations does the school with code BUS has?
assistant
SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'
human
Find the number of classes offered for all class rooms that held at least 2 classes.
assistant
SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2
human
List the codes of all courses that take place in room KLR209.
assistant
SELECT class_code FROM CLASS WHERE class_room = "KLR209" ;