我正在尝试从两个表(部门和人员)中获取一些数据,
我的工作基本上是使用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.
答案 0 :(得分:1)
也许我错了,但是在我看来,您想选择salary
高于平均水平的人。您无需使用group by
和having
就可以实现它。我假设您的桌子上每人只有一行。
select works_in
from email.person
where salary > (select AVG(salary) from email.person)