Last answered:

07 Jul 2023

Posted on:

04 Jul 2023

0

Why we have used dept_code? We only need employee number and manager id. So can we do it like this?

SELECT 
    emp_no AS employee_id,
    (SELECT 
            emp_no
        FROM
            dept_manager
        WHERE
            emp_no = 110022) AS manager_id
FROM
    employees
WHERE
    emp_no BETWEEN 10001 AND 10020 
UNION SELECT 
    emp_no AS employee_id,
    (SELECT 
            emp_no
        FROM
            dept_manager
        WHERE
            emp_no = 110039) AS manager_id
FROM
    employees
WHERE
    emp_no BETWEEN 10021 AND 10040;

1 answers ( 0 marked as helpful)
Instructor
Posted on:

07 Jul 2023

0

Hi Vaibhav!
Thanks for reaching out.


Yes, you can skip the dept_code column.


Hope this helps.
Best,
Tsvetelin

Submit an answer