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
How many professors are teaching class with code ACCT-211?
assistant
SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = 'ACCT-211'
human
What is the first and last name of the oldest employee?
assistant
SELECT emp_fname , emp_lname FROM employee ORDER BY emp_dob LIMIT 1
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 total number of employees.
assistant
SELECT count(*) FROM employee
human
What is the count and code of the job with the most employee?
assistant
SELECT emp_jobcode , COUNT( * ) FROM employee GROUP BY emp_jobcode ORDER BY COUNT( * ) DESC LIMIT 1 ;