OCP-1Z0-051-题目解析-第11题
来源:互联网 发布:Mac pro 怎么看芒果TV 编辑:程序博客网 时间:2024/05/18 02:15
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 a
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.
What would be the outcome if all the parentheses are removed from the above statement?
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 parentheses 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.
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.
Answer: B
题目解析:
题目的意思是:表中产品的价格降价25%后,加上税金15%,再加上运费100后产品的新价格。题目给出了产品新价格的sql语句,
问,如果把该sql语句的括号都去了,结果会怎样?
这题也是考表达式的运算顺序
原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.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执行结果
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
结果是一样的,所以选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了,显示和题目说的不一致。
0 0
- OCP-1Z0-051-题目解析-第11题
- OCP-1Z0-051-题目解析-第1题
- OCP-1Z0-051-题目解析-第2题
- OCP-1Z0-051-题目解析-第3题
- OCP-1Z0-051-题目解析-第4题
- OCP-1Z0-051-题目解析-第5题
- OCP-1Z0-051-题目解析-第6题
- OCP-1Z0-051-题目解析-第7题
- OCP-1Z0-051-题目解析-第8题
- OCP-1Z0-051-题目解析-第9题
- OCP-1Z0-051-题目解析-第10题
- OCP-1Z0-051-题目解析-第12题
- OCP-1Z0-051-题目解析-第13题
- OCP-1Z0-051-题目解析-第14题
- OCP-1Z0-051-题目解析-第15题
- OCP-1Z0-051-题目解析-第16题
- OCP-1Z0-051-题目解析-第17题
- OCP-1Z0-051-题目解析-第18题
- 如何在Struts的Action中直接使用POI生成Excel并下载
- Unity3D教程游戏开发鼠标路线
- Linux 下IPC总结(全)
- 分布式搜索elasticsearch java API 之(八)------使用More like this实现基于内容的推荐
- 【node】关于Most middleware (like session) is no longer bundled with Express and must be installed ……
- OCP-1Z0-051-题目解析-第11题
- button的长按事件
- unable to connect to your virtual device genymotion will now stop check your virtualbox network
- code review
- 关注C++细节——含有本类对象指针的类的构造函数、析构函数、拷贝构造函数、赋值运算符的例子
- svn http支持
- 给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该结点
- 基于安卓的课程设计——加速度检测应用
- hadoop mapreduce 多输入路径