以下是我的查询文本,其中包含语法错误。
select cc, sum(a.hours),b.labcost
from labour a,othshop b
where lab_cd='hs' and a.mon=03 and a.yr=2010
group by a.cc
HAVING a.cc=b.occ AND b.mon=03 and b.yr=2010;
所有表都存在。这个查询的文本有什么问题?
答案 0 :(得分:0)
having
中没有必要,只需:
select a.cc, sum(a.hours),b.labcost
from labour a,othshop b
where lab_cd='hs' and a.mon=03 and a.yr=2010
and a.cc=b.occ AND b.mon=03 and b.yr=2010
group by a.cc, b.labcost
请注意b.labcost
已添加GROUP BY
。否则,您需要对其执行聚合,例如avg(b.labcost)