bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 607. Sales Person

607. Sales Person

Leetcode Solutions

Excluding Salespersons with Orders from Company 'RED'

  1. Join the Orders table with the Company table on the com_id column.
  2. Filter the joined table to only include orders where the company name is 'RED'.
  3. Select the sales_id from the filtered results to identify salespersons who have made sales to 'RED'.
  4. Use the NOT IN clause with a subquery to select all salespersons from the SalesPerson table whose sales_id is not in the list of salespersons who made sales to 'RED'.
  5. Return the name column of the resulting salespersons.
erDiagram
    SalesPerson ||--o{ Orders : ""
    Company ||--o{ Orders : ""
    SalesPerson {
        int sales_id PK
        varchar name
        int salary
        int commission_rate
        date hire_date
    }
    Company {
        int com_id PK
        varchar name
        varchar city
    }
    Orders {
        int order_id PK
        date order_date
        int com_id FK
        int sales_id FK
        int amount
    }

Using LEFT JOIN and IS NULL to Exclude Salespersons with Orders from Company 'RED'

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...