What would be the outcome if all the parenthese s are removed from the above statement?

View the Exhibit and examine the structure of the PRODUCTS table.
All products have a list price.
You issue the following command to display the total price of each product after a discount of 25% and a tax of 15% are applied on it. Freight charges of $100 have to be applied to all the products.
SQL>SELECT prod_name, prod_list_price -(prod_list_price*(25/100))
+(prod_list_price -(prod_list_price*(25/100))*(15/100))+100
AS "TOTAL PRICE"
FROM products;
What would be the outcome if all the parenthese s are removed from the above statement?

View the Exhibit and examine the structure of the PRODUCTS table.

All products have a list price.
You issue the following command to display the total price of each product after a discount of 25%  and a tax of 15% are applied on it. Freight charges of $100 have to be applied to all the products.

SQL>SELECT prod_name, prod_list_price -(prod_list_price*(25/100))
+(prod_list_price -(prod_list_price*(25/100))*(15/100))+100
AS “TOTAL PRICE”
FROM products;

What would be the outcome if all the parenthese s are removed from the above statement?

A.
It produces a syntax error.

B.
The result remains unchanged.

C.
The total price value would be lower than the correct value.

D.
The total price value would be higher than the correct value.



Leave a Reply 11

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


chetan

chetan

why b is correct answer?

kar

kar

CORRECT B IS CORRECT ANSWER

I HAVE TRIED LIKE THIS

SELECT ‘A’,1-(1*(25/100))+(1-(1*(25/100))*(15/100))+100 AS “TOT” FROM DUAL; –101.7125

SELECT ‘A’,1-1*25/100+1-1*25/100*15/100+100 AS “TOT” FROM DUAL; –101.7125

I HAVE TRIED BY GIVEING DIFF VALUES TO TOTAL PRICE..

PRODUCING THE SAME ANSWER FOR BOTH WITH PARAN AND WITHOUT PARAN

user2

user2

“D” is the correct answer.

Or the question is wrong. To output the correct value, it should be:

SQL>SELECT prod_name, prod_list_price -(prod_list_price*(25/100))
+(prod_list_price -(prod_list_price*(25/100)))*(15/100)+100
AS “TOTAL PRICE”
FROM products;

Dipak Upwanshi

Dipak Upwanshi

“B” is correct answer.

With the formula given in que, B is the correct option.

But as per given condition, the formula given in the que is wrong . If formula was,
prod_list_price -(prod_list_price*(25/100))
+(prod_list_price -(prod_list_price*(25/100)))*(15/100)+100
then option D would be the correct answer.

nadia

nadia

B IS CORRECT

Alvin2201

Alvin2201

Yes B. Who think it’s not so can just try it!

Balakrishna

Balakrishna

D IS CORRECT ANSWER

SELECT 100 -(100*(25/100))+(100 -(100*(25/100))*(15/100))+100

25 – ACTUAL VALUE
271.25 – TOTAL VALUE

Balakrishna

Balakrishna

D IS CORRECT ANSWER

SELECT 100 -(100*(25/100))+(100 -(100*(25/100))*(15/100))+100

100 – ACTUAL VALUE
271.25 – TOTAL VALUE

John

John

The question says: What would be the outcome if all the parenthese s are removed

SQL> SELECT 100 -(100*(25/100))+(100 -(100*(25/100))*(15/100))+100 from dual;

100-(100*(25/100))+(100-(100*(25/100))*(15/100))+100
—————————————————-
271.25

SQL> SELECT 100 -100*25/100+100 -100*25/100*15/100+100 from dual;

100-100*25/100+100-100*25/100*15/100+100
—————————————-
271.25

John

John

B is correct answer

SQL> SELECT ename, sal -(sal*(25/100)) +(sal -(sal*(25/100))*(15/100))+100 FROM bonus;

ENAME SAL-(SAL*(25/100))+(SAL-(SAL*(25/100))*(15/100))+100
———- —————————————————-
joao 9518.75
jose 10375
joana 12087.5

SQL> SELECT ename, sal -sal*25/100 +sal -sal*25/100*15/100+100 FROM bonus;

ENAME SAL-SAL*25/100+SAL-SAL*25/100*15/100+100
———- —————————————-
joao 9518.75
jose 10375
joana 12087.5

mariusftc

mariusftc

STOP ! It is a trap 🙂 !
b, it is obvious!
Simple operator precedence !

* and / executes first ( before + and minus )!
So the parenthesis are superfluous!