코딩테스트연습(SQL)

607. Sales Person / LeetCode, SQL, MySQL

LearnerToRunner 2023. 3. 13. 21:00

문제

source: LeetCode
Write an SQL query to report the names of all the salespersons who did not have any orders related to the company with the name "RED".

Return the result table in any order.

 

 

 

 

제출답안(MySQL)

WITH red_sp AS (
    SELECT sales_id
    FROM orders
    WHERE com_id = (SELECT com_id FROM company WHERE name ='RED')
)

SELECT name
FROM salesperson
WHERE sales_id NOT IN (SELECT sales_id FROM red_sp)

 

 

 

 

문제 바로가기(MySQL)

728x90