What would be the outcome of the above statement?

View the Exhibit and examine the data in EMPLOYEES and DEPARTMENTS tables. In the EMPLOYEES table EMPLOYEE_ID is the PRIMARY KEY and DEPARTMENT_ID is the FOREIGN KEY. In the DEPARTMENTS table DEPARTMENT_ID is the PRIMARY KEY.
Evaluate the following UPDATE statement:
UPDATE employees a
SET department_id =
(SELECT department_id
FROM departments
WHERE location_id = ‘2100’),
(salary, commission_pct) =
(SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct)
FROM employees b
WHERE a.department_id = b.department_id)
WHERE first_name||’ ‘||last_name = ‘Amit Banda’;
What would be the outcome of the above statement? What would be the outcome of the above statement?

View the Exhibit and examine the data in EMPLOYEES and DEPARTMENTS tables.

In the EMPLOYEES table EMPLOYEE_ID is the PRIMARY KEY and DEPARTMENT_ID is the FOREIGN KEY. In the DEPARTMENTS table DEPARTMENT_ID is the PRIMARY KEY.

Evaluate the following UPDATE statement:
UPDATE employees a
SET department_id =
(SELECT department_id
FROM departments
WHERE location_id = ‘2100’),
(salary, commission_pct) =
(SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct)
FROM employees b
WHERE a.department_id = b.department_id)
WHERE first_name||’ ‘||last_name = ‘Amit Banda’;

What would be the outcome of the above statement?

A.
It would execute successfully and update the relevant data.

B.
It would not execute successfully because there is no LOCATION_ID 2100 in the DEPARTMENTS table.

C.
It would not execute successfully because the condition specified with the concatenation operator is not valid.

D.
It would not execute successfully because multiple columns (SALARY,COMMISSION_PCT)cannot be used in an UPDATE statement.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


user

user

update empu set (ename ,sal, deptno) =
(select ‘John’, 9000, 70 from dual) where empno =1;

user

user

update empu
set empno = (select 1 from dual),
(ename ,sal, deptno) =
(select ‘John’, 9000, 70 from dual) where empno = 1;

user

user

those two above query are okay to run

Cindy

Cindy

What’s the result of this part “SET department_id =
(SELECT department_id
FROM departments
WHERE location_id = ‘2100’)”?
It doesn’t result in any updates to the table right?

robkam

robkam

It will set department_id to NULL

Vietnam (anticomunism)

Vietnam (anticomunism)

Yes, you’re right!