3 回答
TA贡献1802条经验 获得超5个赞
使用 across join生成员工和时间段的所有组合。然后使用 a left join(or not inor not exists) 过滤掉那些存在的:
select e.emp, ts.*
from employee e cross join
timeslots ts left join
scheduling s
on s.emp = e.emp and s.timeslot_id = ts.timeslot_id
where s.emp is null;
TA贡献1847条经验 获得超7个赞
SELECT e.*, t.*
FROM employee e
CROSS JOIN
TimeSlot t
WHERE NOT EXISTs (
SELECT 0 FROM Scheduling s2
JOIN TimeSlot t2
ON s2.empid = e.empid
AND t2.endTime > t.StartTime
AND t2.startTime < t.EndTime
) --where there is not some other overlapping timeslot allocated
- 3 回答
- 0 关注
- 156 浏览
添加回答
举报