OCP-1Z0-051-Question Analysis-11th question

Source: Internet
Author: User

11. 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 atax 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 wocould be the outcome if all the parentheses are removed from the above statement? A. It produces a syntax error.
B. The result remains unchanged.
C. The total price value wocould be lower than the correct value.
D. The total price value wocould be higher than the correct value. Answer: B Question Analysis: The question is: after the price of the products in the table is reduced by 25%, the tax is increased by 15%, and the new price of the products after the freight is increased by 100. The question shows the SQL statement for the new product price, Q: What will happen if I put all the parentheses in the SQL statement? This is also the calculation order of the test expression. Original SQL Execution result
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 where rownum<10;     PROD_NAME                         TOTAL PRICE  --------------------------------- -----------  VRAM - 64 MB                      577.7875CPU D300                          272.9625CPU D400                          310.6375CPU D600                           404.825GP 1024x768                        233.575GP 1280x1024                       267.825GP 800x600                           182.2MB - S300                         194.1875MB - S450                          213.025

SQL Execution result after parentheses

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 where rownum<10;     PROD_NAME                         TOTAL PRICE  --------------------------------- -----------  VRAM - 64 MB                      577.7875CPU D300                          272.9625CPU D400                          310.6375CPU D600                           404.825GP 1024x768                        233.575GP 1280x1024                       267.825GP 800x600                           182.2MB - S300                         194.1875MB - S450                          213.025

The result is the same, so select B.

In fact, the question should be wrong in the brackets of the SQL statement.

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;

If the question is given with brackets, you can test

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

The result is 271.25, which is different from the question.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.