607. 销售员 难度:简单

1、题目描述

607. 销售员 难度:简单_第1张图片
607. 销售员 难度:简单_第2张图片
来源:力扣(LeetCode)

2、解题思路

思路一

1# 首先找出卖给RED的销售
2# 然后取不在1#条件内的销售where s2.sales_id not in

思路二

#1 主要是对于company表的RED进行取反,以salesperson为主表:right join salesperson s
#2 条件是c.name='RED',然后取反where o.order_id is null,空值就表面c.name不等于'RED'

3、提交记录

##思路一

select s2.name
from salesperson s2
where s2.sales_id not in(
select o.sales_id
from orders o join company c 
on o.com_id=c.com_id 
where c.name like 'RED' ) 

##思路二

select s.name
from orders o join company c 
on o.com_id=c.com_id 
right join salesperson s
on s.sales_id=o.sales_id and c.name='RED'
where o.order_id is null

你可能感兴趣的:(刷题)