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 the number of professors in accounting department.
assistant
SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = 'Accounting'
human
List the first name of all employees with job code PROF ordered by their date of birth.
assistant
SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob
human
Find the first names of professors who are teaching more than one class.
assistant
SELECT T2.emp_fname FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num GROUP BY T1.prof_num HAVING count(*) > 1
human
Find the first names of all professors in the Accounting department who is teaching some course and the class room.
assistant
SELECT T2.emp_fname , T1.class_room FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN professor AS T3 ON T2.emp_num = T3.emp_num JOIN department AS T4 ON T4.dept_code = T3.dept_code WHERE T4.dept_name = 'Accounting'
human
list names of all departments ordered by their names.
assistant
SELECT dept_name FROM department ORDER BY dept_name
human
Find the first names and offices of all professors sorted by alphabetical order of their first name.
assistant
SELECT T2.emp_fname , T1.prof_office FROM professor AS T1 JOIN employee AS T2 ON T1.emp_num = T2.emp_num ORDER BY T2.emp_fname ;