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;