我正在使用此代碼:
create or replace view VIEW_MAXMIN as
select c.country_name,
max(salary) max_salary,
min(salary) min_salary
from employees e,
departments d,
locations l,
countries c
where e.department_id = d.department_id
and d.location_id = l.location_id
and l.country_id = c.country_id = not in(select country_name
from countries
where country_name = 'Mexico');
但總是錯誤提示“SQL 命令未正確結束”
uj5u.com熱心網友回復:
您可以將連接從舊版 Oracle 逗號連接更改為 ANSI 連接,然后看起來您想要名稱不是 的國家/地區Mexico。
此外,如果您正在聚合列并且有一列您沒有聚合,那么您需要使用GROUP BY:
create or replace view VIEW_MAXMIN as
select c.country_name,
max(salary) max_salary,
min(salary) min_salary
from employees e
INNER JOIN departments d
ON (e.department_id = d.department_id)
INNER JOIN locations l
ON (d.location_id = l.location_id)
INNER JOIN countries c
ON (l.country_id = c.country_id)
where c.country_name != 'Mexico'
GROUP BY c.country_name;
uj5u.com熱心網友回復:
看起來您特別遇到的錯誤是由于 -
l.country_id = c.country_id = not in(select country_name
from countries
where country_name = 'Mexico');
在一個過濾器陳述句中有 2 個等于條件 - 就像 a = b = c 只是 -l.country_id = c.country_id就足夠了,并且country_name != 'Mexico'必須是一個單獨的條件
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/333124.html
