标签:ror top code images 12px 意思 str tracking correct
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;
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.7875 CPU D300 272.9625 CPU D400 310.6375 CPU D600 404.825 GP 1024x768 233.575 GP 1280x1024 267.825 GP 800x600 182.2 MB - S300 194.1875 MB - S450 213.025
去括号后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 where rownum<10; PROD_NAME TOTAL PRICE --------------------------------- ----------- VRAM - 64 MB 577.7875 CPU D300 272.9625 CPU D400 310.6375 CPU D600 404.825 GP 1024x768 233.575 GP 1280x1024 267.825 GP 800x600 182.2 MB - S300 194.1875 MB - S450 213.025
结果是一样的,所以选B
事实上这道题,题目给的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;
假设是题目给的括号位置,能够測试下
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
结果是271.25了,显示和题目说的不一致。
标签:ror top code images 12px 意思 str tracking correct
原文地址:http://www.cnblogs.com/tlnshuju/p/7098504.html