leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

sales-person.sql (511B)


      1 --Find all sales people who do not have any experience trading with 
      2 --the "RED" customer.
      3 --I used not in to check that the name was not in the list of names that traded with that group.
      4 SELECT S.name
      5 FROM SalesPerson AS S
      6 LEFT JOIN Orders AS O
      7 ON O.sales_id = S.sales_id
      8 LEFT JOIN Company AS C
      9 ON C.com_id = O.com_id
     10 WHERE S.name NOT IN
     11 (
     12 SELECT S.name
     13 FROM SalesPerson AS S
     14 LEFT JOIN Orders AS O
     15 ON O.sales_id = S.sales_id
     16 LEFT JOIN Company AS C
     17 ON C.com_id = O.com_id
     18 WHERE C.name = "RED"
     19 )
     20 GROUP BY S.name