查询的语法有什么问题?
What is wrong with the query's syntax?
这是我的查询文本,但有语法错误。
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;
所有表格都存在。此查询的文本有什么问题?
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)
这是我的查询文本,但有语法错误。
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;
所有表格都存在。此查询的文本有什么问题?
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)