我有一个包含员工和任务的表,我想要一个缺少员工/任务组合的列表。
Bob Gardening
Bob Watering
Jane Gardening
Jane Digging因此,select将生成
Bob Digging
Jane Watering有什么建议吗?谢谢
发布于 2017-04-06 01:28:20
交叉联接创建员工和任务的所有可能组合。使用NOT IN,您可以从以下集合中减去所有现有的员工/工作组合:
select e.employee, t.task
from employees e
cross join task t
where (e.employee, t.task) not in
(
select employee, task
from employees_tasks
);发布于 2017-04-06 01:44:25
您需要将所有员工作为一个子查询,将所有任务作为另一个子查询,然后进行交叉连接。完成后,如下所示给出条件。
Select * from (
select a.employee,b.task from
(Select distinct employee from table) a, (select distinct task from table) b) where (employee,task) not in (select employee, task from table)https://stackoverflow.com/questions/43237776
复制相似问题