exam questions

Exam 1z0-061 All Questions

View all questions & answers for the 1z0-061 exam

Exam 1z0-061 topic 4 question 61 discussion

Actual exam question from Oracle's 1z0-061
Question #: 61
Topic #: 4
[All 1z0-061 Questions]

Examine the structure and data in the PRICE_LIST table:

Name . Null . Type -
----------------------
PROD_ID . NOT NULL . NUMBER(3)
PROD_PRICE . VARCHAR2(10)

PROD_ID PROD_PRICE -
----------------------
100 $234.55
101 $6, 509.75
102 $1, 234
You plan to give a discount of 25% on the product price and need to display the discount amount in the same format as the PROD_PRICE.
Which SQL statement would give the required result?

  • A. SELECT TO_CHAR(prod_price* .25, '$99, 999.99') FROM PRICE_LIST;
  • B. SELECT TO_CHAR(TO_NUMBER(prod_price)* .25, '$99, 999.00') FROM PRICE_LIST;
  • C. SELECT TO_CHAR(TO_NUMBER(prod_price, '$99, 999.99')* .25, '$99, 999.00') FROM PRICE_LIST;
  • D. SELECT TO_NUMBER(TO_NUMBER(prod_price, '$99, 999.99')* .25, '$99, 999.00') FROM PRICE_LIST;
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
Use TO_NUMBER on the prod_price column to convert from char to number to be able to multiply it with 0.25. Then use the TO_CHAR function (with formatting'$99, 999.00') to convert the number back to char.

Incorrect:
Not C: Use the formatting'$99, 999.00' with the TO_CHAR function, not with the TO_NUMBER function.
Note:
* Using the TO_CHAR Function
The TO_CHAR function returns an item of data type VARCHAR2. When applied to items of type NUMBER, several formatting options are available. The syntax is as follows:
TO_CHAR(number1, [format], [nls_parameter]),
The number1 parameter is mandatory and must be a value that either is or can be implicitly converted into a number. The optional format parameter may be used to specify numeric formatting information like width, currency symbol, the position of a decimal point, and group (or thousands) separators and must be enclosed in single
* Syntax of Explicit Data Type Conversion

Functions -
TO_NUMBER(char1, [format mask], [nls_parameters]) = num1
TO_CHAR(num1, [format mask], [nls_parameters]) = char1
TO_DATE(char1, [format mask], [nls_parameters]) = date1
TO_CHAR(date1, [format mask], [nls_parameters]) = char1

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
winston
1 year, 3 months ago
Correct answer is B you first need to convert the product price to a number TO_NUMBER('product price') then multiply by .25 before you display the out put as a character string in this format '$99,999.00'
upvoted 1 times
...
hggz
5 years, 2 months ago
Correct Answer: C You can check: SELECT TO_CHAR('$6,509.75'* .25, '$99,999.99') FROM DUAL; SELECT TO_CHAR(TO_NUMBER('$6,509.75')* .25, '$99,999.00') FROM DUAL; SELECT TO_CHAR(TO_NUMBER('$6,509.75', '$99,999.99')* .25, '$99,999.00') FROM DUAL; SELECT TO_NUMBER(TO_NUMBER('$6,509.75', '$99,999.99')* .25, '$99,999.00') FROM DUAL;
upvoted 3 times
...
Sugar
5 years, 3 months ago
B is correct. no doubt
upvoted 2 times
newtonlight
3 years, 10 months ago
you are wrong,reference below
upvoted 1 times
...
jery
3 years, 10 months ago
B is wrong
upvoted 1 times
...
...
Oliver8520
5 years, 6 months ago
Correct Answer: C
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago