• Matéria: Informática
  • Autor: ldrmt
  • Perguntado 5 anos atrás

Com base no DER abaixo, qual a construção correta para a solicitaçãoseguinte? Encontre os empregados que têm, no mínimo, uma pessoa subordinada a cada um deles.




a.
SELECT EMPLOYEE_ID, MANAGER_ID, FIRST_NAME, LAST_NAME,

JOB_ID, DEPARTMENT_ID, SALARY

FROM EMPLOYEES E

WHERE EXISTS (SELECT EMPLOYEE_ID

FROM EMPLOYEES

WHERE EMPLOYEES.MANAGER_ID =

E. EMPLOYEE_ID)

ORDER BY EMPLOYEE_ID;

b.
SELECT EMPLOYEE_ID, MANAGER_ID, FIRST_NAME, LAST_NAME,

JOB_ID, DEPARTMENT_ID, SALARY

FROM EMPLOYEES E

WHERE NOT EXISTS (SELECT EMPLOYEE_ID

FROM EMPLOYEES

WHERE EMPLOYEES.MANAGER_ID =

E. EMPLOYEE_ID)

ORDER BY EMPLOYEE_ID;

c.
SELECT EMPLOYEE_ID, MANAGER_ID, FIRST_NAME, LAST_NAME,

JOB_ID, DEPARTMENT_ID, SALARY

FROM EMPLOYEES E

WHERE EXISTS (SELECT EMPLOYEE_ID

FROM EMPLOYEES)

ORDER BY EMPLOYEE_ID;

d.
SELECT EMPLOYEE_ID, MANAGER_ID, FIRST_NAME, LAST_NAME,

JOB_ID, DEPARTMENT_ID, SALARY

FROM EMPLOYEES E

WHERE EMPLOYEE_ID >= (SELECT EMPLOYEE_ID

FROM EMPLOYEES

WHERE EMPLOYEES.MANAGER_ID =

E. EMPLOYEE_ID)

ORDER BY EMPLOYEE_ID;

e.
SELECT EMPLOYEE_ID, MANAGER_ID, FIRST_NAME, LAST_NAME,

JOB_ID, DEPARTMENT_ID, SALARY

FROM EMPLOYEES E

WHERE EXISTS IN (SELECT EMPLOYEE_ID

FROM EMPLOYEES

WHERE EMPLOYEES.MANAGER_ID =

E. EMPLOYEE_ID)

ORDER BY EMPLOYEE_ID;

Respostas

respondido por: kurokaji
14

Resposta:

Resposta:

A:

Explicação:

SELECT

  EMPLOYEE_ID,

  MANAGER_ID,

  FIRST_NAME,

  LAST_NAME,

  JOB_ID,

  DEPARTMENT_ID,

  SALARY

FROM

  EMPLOYEES

WHERE

  EXISTS( SELECT

          EMPLOYEE_ID

      FROM

          EMPLOYEES

      WHERE

          EMPLOYEES.MANAGER_ID = E.EMPLOYEE_ID)

ORDER BY EMPLOYEE_ID;

Perguntas similares