【发布时间】:2012-04-20 17:46:57
【问题描述】:
我有一个表员工,它具有不同的属性,如 emp_code、naeme、....、deptt。 还有一个名为 nightShift 的表,其中包含字段 emp_code、shift_time。 任何不在夜班表中的员工都被自动假定为白班。
现在我必须找出那些有一些员工在夜班工作而一些在正常值班的部门 这可以是什么查询。
例子
**Employees**
----------------------------------------
emp_code| Name | deptt
----------------------------------------
e1 John Ops
e2 Martin Ops
e3 Gary Infra
e4 John Facilities
e5 Michael Ops
e6 Alan Ops
e7 Tony Facilites
e8 Alex Infra
e9 Peter Infra
e10 Ron Ops
**nightShift**
----------------------------------------
emp_code | shift_time
----------------------------------------
e1 shiftA
e2 shiftA
e5 shiftB
e4 shiftB
e7 shiftC
现在在输出中,我只想要 Deptt Ops,因为它的一些员工在夜班 (e1,e2,e5) 和一些在正常值班 (e6,e10) 输出不应包含 Infra,因为所有员工(e3、e8、e9)都在正常值班,而没有夜班。 输出不应包含设施,因为所有员工 (e4,e7) 都在夜班,没有人在正常值班。
有人可以帮我解决这个问题吗?
【问题讨论】: