Skip to content

Commit 03b8a59

Browse files
authored
Update 09-00607-sales-person.sql
1 parent cff8c04 commit 03b8a59

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

09-00607-sales-person.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1+
-- nested query
2+
-- select all salesPerson with company RED
3+
-- select all salesPerson from SalesPerson not in the above table
14

5+
select sp.name
6+
from SalesPerson sp
7+
where sales_id not in
8+
(select o.sales_id
9+
from Orders o
10+
where o.com_id in
11+
(select c.com_id
12+
from Company c
13+
where c.name = 'RED'))
14+
15+
------------------------------------------------------------------------------------------------------------------------------------------------
16+
-- JOIN Company c and Ordered o
17+
-- pick all sales_id with company = 'RED'
18+
-- pick all salesPerson from SalesPerson not in temp table above
19+
20+
select sp.name
21+
from SalesPerson sp
22+
where sales_id not in
23+
(select o.sales_id
24+
from Orders o
25+
inner join Company c
26+
on c.com_id = o.com_id
27+
where c.name = 'RED')
28+
29+
30+
-- no companies listed

0 commit comments

Comments
 (0)