我的問題是代碼是代碼返回員工的最高工資,包括管理員 當我想要它排除管理人員。SQL - SELECTING MAX返回不同的列
除了它的作品。
這裏是我寫的代碼:
SELECT firstname || ' ' || lastname
AS "FULL NAME"
FROM EMPLOYEES
WHERE salary =
(SELECT MAX(salary)
FROM EMPLOYEES, DEPARTMENTS
WHERE NOT employee_id = manager_id);
這裏是數據庫架構
COUNTRIES(country_id, country_name, region)
• Primary key: {country_id}
DEPARTMENTS(department_id, department_name, manager_id)
• Primary key: {department_id }
• Foreign key: [manager_id] ⊆ EMPLOYEES[employee_id]
DEPT_LOCATIONS(department_id, city, country_id)
• Primary key: {department_id, city}
• Foreign key: [department_id] ⊆ DEPARTMENTS[department_id] and
[country_id] ⊆ COUNTRIES[country_id]
EMPLOYEES(employee_id, firstname, lastname, email, phone_no, salary,
department_id)
• Primary key: {employee_id}
• Foreign key: [department_id] ⊆ DEPARTMENTS[department_id]
任何幫助非常讚賞。
第二個解決了這個問題 –