【发布时间】:2016-04-06 13:15:39
【问题描述】:
我在 oracle 中使用 northwind 数据库。
任务: 取号在每个地区工作的员工人数。
结果: (地区名称,员工人数)
我正在尝试这个查询,但它返回笛卡尔积
select r.regiondescription, count(e.employeeid)
from employees e,
employeeterritories et,
territories t,
region r
where r.regionid = t.regionid
and et.territoryid = t.territoryid
and e.employeeid = et.employeeid
group by r.regiondescription;
问题:我的查询有什么问题?
【问题讨论】:
-
哪些表之间的笛卡尔积?你的意思是在分组之前返回笛卡尔积吗?您能否发布一个数据样本以及您现在得到的结果以及您的预期?
-
我找不到该查询有什么问题。 (嗯,你应该使用现代的显式 JOIN 语法,而不是旧的隐式连接语法......)
-
检查一下我已经上传了
-
您的表中有多少员工?
-
@rontornambe 它已经在 where 子句中了,两次!
标签: sql database oracle northwind