Which change must be made to the above syntax to calculate the annual compensation as "monthly salary plus a monthly bonus of $100, multiplied by 12"?

Evaluate this SQL statement:
SELECT ename, sal, 12*sal+100
FROM emp;
The SAL column stores the monthly salary of the employee. Which change must be made to the
above syntax to calculate the annual compensation as “monthly salary plus a monthly bonus of
$100, multiplied by 12″?

Evaluate this SQL statement:
SELECT ename, sal, 12*sal+100
FROM emp;
The SAL column stores the monthly salary of the employee. Which change must be made to the
above syntax to calculate the annual compensation as “monthly salary plus a monthly bonus of
$100, multiplied by 12″?

A.
SELECT ename, sal, 12*(sal+100)
FROM emp;

B.
SELECT ename, sal+100,*12
FROM emp;

C.
No change is required to achieve the desired results.

D.
SELECT ename, sal, (12*sal)+100
FROM emp;

Explanation:

:
to achieve the result you must add 100 to sal before multiply with 12.
Select ename, sal, 12*(sal+100) from EMP;
Incorrect answer :
* Multiplication and division has priority over addition and subtraction in Operator precedence.
C Give wrong results
D Wrong syntax
Refer : Introduction to Oracle9i : SQL, Oracle University Study Guide, 1-11



Leave a Reply 1

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