1z0-071 Exam QuestionsBrowse all questions from this exam

1z0-071 Exam - Question 2


Examine the description of the PRODUCTS table:

Which three queries use valid expressions? (Choose three.)

Show Answer
Correct Answer: BCF

The three queries that use valid expressions are: 1. SELECT product_id, (unit_price * 0.15 / (4.75 + 552.25)) FROM products; This query is valid because it uses a mathematical expression involving unit_price, which is of type NUMBER. 2. SELECT product_id, (expiry_date - delivery_date) * 2 FROM products; This query is valid because it calculates the difference between two dates, which yields a NUMBER representing the number of days between them. This result can then be multiplied by 2. 3. SELECT product_id, unit_price, unit_price + surcharge FROM products; This query is valid assuming that the VARCHAR2 column surcharge contains numeric values. Oracle SQL implicitly converts VARCHAR2 to NUMBER in such cases, making the addition valid.

Discussion

15 comments
Sign in to comment
dumpsvibeOptions: BCF
Jun 21, 2024

B and C are right but F is a tricky one

GunduzHuseynliOptions: BCE
Sep 3, 2022

BCE should be correct answer cause number+varchar in this case imspossible

extopic01
Sep 12, 2022

Have u tried it yourself in livesql.oracle.com? Number + varchar is possible due to implicit casting, so BCF is correct.

gioves28
Sep 29, 2022

E is wrong inconsistent datatypes: expected NUMBER got DATE

gabolkaOptions: BCF
Sep 4, 2022

you cant multiply date, BCF correct if varchar2 is number

Efstathia
Sep 6, 2022

Just to say the same things in other words.... If surcharge column contains numeric values (even as varchar2 type) can be implicitly converted

CyberP
May 26, 2023

If you cant multiply date, then why you chose c ? since c the date is also multiply ?

MySekQL
Sep 4, 2023

I'm guessing because if you subtract two dates that are relatively close, you will get a number not a date. And that CAN be multiplied.

MZEnuovazelandaOptions: BCF
Sep 6, 2022

IT is correct BCF because in the Datatype Varchar2 there may be a number. Oracle makes it an implicit cast and uses it as a number

fantastic_side_eyeOptions: BCF
Jun 25, 2023

BCF The three queries that use valid expressions are: B. SELECT product_id, (unit_price * 0.15 / (4.75 + 552.25)) FROM products; C. SELECT product_id, (expiry_date - delivery_date) * 2 FROM products; F. SELECT product_id, unit_price, unit_price + surcharge FROM products; Explanation: A. This query is invalid because the alias "S" is not defined anywhere in the query. B. This query is valid. It calculates a value based on the unit price of each product using a mathematical expression. C. This query is valid. It calculates the difference between the expiry date and delivery date for each product and multiplies it by 2. D. This query is invalid because the alias "discount" is not defined anywhere in the query. E. This query is invalid because you cannot multiply a date value by a number. F. This query is valid. It selects the product ID, unit price, and the sum of the unit price and surcharge for each product.

jm9999Options: BCF
Sep 15, 2023

Seems like a sketchy question, have to assume surcharge contains only numerical characters in the string for F

AveragenoobOptions: BCE
Sep 2, 2022

bce should be

Indhumathishan
May 4, 2023

why is D incorrect?

NelitaOptions: BCF
May 4, 2023

B-C-F IS CORRECT IF the varchar-column has stored number.

zouve
Jun 18, 2023

select '2'+3 from dual; it produces the SUM correctly so F is correct

Lee_jong_sukOptions: BCF
Dec 8, 2023

BCF is correct answer Please note: date+date is not allowed

holdfaststrongly
Sep 20, 2022

Is "-discount" in AD supposed to be an alias for the column?

TMerloOptions: BCF
Oct 2, 2023

It´s not a right decision plus a NUMBER with VARCHAR2 fields.

tom2992Options: BCF
Apr 22, 2024

A and D wrong cause they have invalid identifier "Discount". E wrong cause date can't multiple with number.

alelejajaOptions: BCF
May 22, 2024

B and C clearly correct. F is tricky. It can be correct only if the column Surcharge contains numeric characters defined as varchar2