【发布时间】:2014-03-31 19:22:18
【问题描述】:
SELECT e.name
from emp e, departm d, salery s
WHERE e.dep=d.depid
AND s.emp= e.empid
AND s.sal > (SELECT round(avg(s.sal)) as AVGSAL
from emp e, departm d, salery s
WHERE e.dep=d.depid AND s.emp= e.empid
GROUP BY d.depid
);
我的桌子是:
emp (empid, name, dep)
departm (depid, name, headdep)
salery (emp, cost, sal, fdate)
我有一些外键:
部门:FOREIGN KEY (headdep) REFERENCES departm(depid)
员工:FOREIGN KEY(dep) REFERENCES departm(depid)
销售:FOREIGN KEY(emp) REFERENCES emp(empid)
我想打印一份收入高于部门平均水平的所有员工的列表,但是当我运行此查询时出现错误:single-row subquery returns more than one row
谁能帮助我?我的查询有什么问题? 最后我想创建一个过程,但首先我必须编写查询。
谢谢你们……
【问题讨论】:
-
什么是 m.abt 列.. 没有表别名 m.. 更正它