在 SINGLE SQL 语句中计算豁免员工的最低工资和非豁免员工的平均工资。使用子查询将这两个元素合并到查询中。它应该看起来像:
Min Exempt Salary Average Non-Exempt Salary
47,000 35,271
我知道如何分开做,但无法像上面所说的那样弄清楚如何做,这是我的陈述。
SELECT jobs1.exempt_nonexempt_status,
Min (employees.salary)AS Minimal_Exempt_Salary
FROM employees
LEFT JOIN jobs1
ON employees.job_title = jobs1.job_title
WHERE jobs1.exempt_nonexempt_status = 'Exempt'
GROUP BY jobs1.exempt_nonexempt_status
SELECT jobs1.exempt_nonexempt_status,
Avg (employees.salary)AS Average_Non_Exempt_Salary
FROM employees
LEFT JOIN jobs1
ON employees.job_title = jobs1.job_title
WHERE jobs1.exempt_nonexempt_status = 'Non-exempt'
GROUP BY jobs1.exempt_nonexempt_status