SQL 查询

列出本世纪出生的收入超过 5 万美元的员工。列出他们的姓名,出生日期和工资,按名称按字母顺序排序。

SELECT employee_name, date_of_birth, salary
FROM   employees
WHERE  salary > 50000
   AND date_of_birth >= DATE '2000-01-01'
ORDER BY employee_name;

显示每个部门至少有 5 名员工的员工人数。首先列出最大的部门。

SELECT department_id, COUNT(*)
FROM   employees
GROUP BY department_id
HAVING COUNT(*) >= 5
ORDER BY COUNT(*) DESC;