使用 In 命令和 group by 子句
Working with In command and group by clause
我正在尝试从两个表(部门和人员)中获取一些数据,
我的工作基本上是使用 in
子句。谁能帮我找出以下查询中的问题?
from email.department, email.person
where person.works_in in (select person.works_in from email.person
having salary > avg(person.salary) group by (person.works_in));
ERROR: syntax error at or near "group"
LINE 16: having salary > avg(salary) group by (person.wo.
I am getting the above error
UPDATED:
select person.works_in from email.person
group by person.salary,person.works_in
having salary > avg(salary);
the query is executed but, Now, I get nothing in the return value.
也许我错了,但在我看来,您希望 select 人 salary
高于平均水平。您可以在不使用 group by
和 having
的情况下实现它。我假设您的 table.
中每人一行
select works_in
from email.person
where salary > (select AVG(salary) from email.person)
我正在尝试从两个表(部门和人员)中获取一些数据,
我的工作基本上是使用 in
子句。谁能帮我找出以下查询中的问题?
from email.department, email.person
where person.works_in in (select person.works_in from email.person
having salary > avg(person.salary) group by (person.works_in));
ERROR: syntax error at or near "group"
LINE 16: having salary > avg(salary) group by (person.wo.
I am getting the above error
UPDATED:
select person.works_in from email.person
group by person.salary,person.works_in
having salary > avg(salary);
the query is executed but, Now, I get nothing in the return value.
也许我错了,但在我看来,您希望 select 人 salary
高于平均水平。您可以在不使用 group by
和 having
的情况下实现它。我假设您的 table.
select works_in
from email.person
where salary > (select AVG(salary) from email.person)