Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 1z0-082 topic 1 question 71 discussion

Actual exam question from Oracle's 1z0-082
Question #: 71
Topic #: 1
[All 1z0-082 Questions]

The CUSTOMERS table has a CUST_CREDIT_LIMIT column of data type NUMBER.
Which two queries execute successfully? (Choose two.)

  • A. SELECT NVL(cust_credit_limit * .15, 'Not Available') FROM customers;
  • B. SELECT NVL2(cust_credit_limit * .15, 'Not Available') FROM customers;
  • C. SELECT NVL(TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers;
  • D. SELECT TO_CHAR(NVL(cust_credit_limit * .15, 'Not Available')) FROM customers;
  • E. SELECT NVL2(cust_credit_limit, TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers;
Show Suggested Answer Hide Answer
Suggested Answer: CE 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
you1234
Highly Voted 3 years, 10 months ago
A) SELECT NVL(cust_credit_limit * .15, 'Not Available') FROM customers; B) SELECT NVL2(cust_credit_limit * .15, 'Not Available') FROM customers; C) SELECT NVL(TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; D) SELECT TO_CHAR(NVL(cust_credit_limit * .15, 'Not Available')) FROM customers; E) SELECT NVL2(cust_credit_limit, TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; Correct C & E.
upvoted 16 times
ama
3 years, 9 months ago
YES C & E
upvoted 3 times
...
Ekos
3 years, 6 months ago
correct, C & E
upvoted 3 times
...
...
valiantvimal
Most Recent 2 weeks, 3 days ago
Selected Answer: CE
C, E are correct. Reason why A is not correct is NVL function expects the cust_credit_limit column to be of same datatype as Replacement value ('Not Available' here). So it has to be converted to string (TO CHAR) to achieve it.
upvoted 1 times
valiantvimal
2 weeks, 3 days ago
Result will be like: SQL> SELECT NVL(cust_credit_limit * .15, 'Not Available') FROM customers; SELECT NVL(cust_credit_limit * .15, 'Not Available') FROM customers * ERROR at line 1: ORA-01722: invalid number SQL> SELECT NVL(TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; NVL(TO_CHAR(CUST_CREDIT_LIMIT*.15),'NOTA ---------------------------------------- 150 750.0375 Not Available SQL> SELECT NVL2(cust_credit_limit, TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; NVL2(CUST_CREDIT_LIMIT,TO_CHAR(CUST_CRED ---------------------------------------- 150 750.0375 Not Available You can see that in the First Query 'Not Available' is not accepted as a Replacement for the Column with Number Datatype. So once Number Datatype is converted into CHAR, the 'Not Available' string gets displayed.
upvoted 1 times
...
valiantvimal
2 weeks, 3 days ago
If the Replacement Value is a Number instead of 'Not Available', NVL will accept it since the cust_credit_limit column's datatype is Number.
upvoted 1 times
...
...
Lalala8
7 months, 2 weeks ago
Selected Answer: CE
C. SELECT NVL(TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; This query will return the value of the cust_credit_limit column multiplied by 0.15, converted to a character value, if the cust_credit_limit column is not null. Otherwise, it will return the string 'Not Available'. E. SELECT NVL2(cust_credit_limit, TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; This query will return the value of the cust_credit_limit column if it is not null. Otherwise, it will return the value of the expression TO_CHAR(cust_credit_limit * .15), converted to a character value. If the expression TO_CHAR(cust_credit_limit * .15) is null, the NVL2() function will return the string 'Not Available'.
upvoted 1 times
...
j_tw
1 year ago
I don't know why not A ?
upvoted 1 times
valiantvimal
2 weeks, 3 days ago
You can see that in the First Query given below that 'Not Available' is not accepted as a Replacement for the Column with Number Datatype. So once Number Datatype is converted into CHAR, the 'Not Available' string gets displayed. If the Replacement Value is a Number instead of 'Not Available', NVL will accept it since the cust_credit_limit column's datatype is Number.
upvoted 1 times
...
valiantvimal
2 weeks, 3 days ago
Result will be like: SQL> SELECT NVL(cust_credit_limit * .15, 'Not Available') FROM customers; SELECT NVL(cust_credit_limit * .15, 'Not Available') FROM customers * ERROR at line 1: ORA-01722: invalid number SQL> SELECT NVL(TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; NVL(TO_CHAR(CUST_CREDIT_LIMIT*.15),'NOTA ---------------------------------------- 150 750.0375 Not Available SQL> SELECT NVL2(cust_credit_limit, TO_CHAR(cust_credit_limit * .15), 'Not Available') FROM customers; NVL2(CUST_CREDIT_LIMIT,TO_CHAR(CUST_CRED ---------------------------------------- 150 750.0375 Not Available
upvoted 1 times
...
valiantvimal
2 weeks, 3 days ago
C, E are correct. Reason why A is not correct is NVL function expects the cust_credit_limit column to be of same datatype as Replacement value ('Not Available' here). So it has to be converted to string (TO CHAR) to achieve it.
upvoted 1 times
...
auwia
10 months, 2 weeks ago
Implicit cast is never easy to understand on fly, so oracle (and many others) recommend to try to avoid them.
upvoted 1 times
...
...
XhostSI
2 years, 2 months ago
Adopted to HR Schema: SELECT NVL(TO_CHAR(commission_pct * .15), 'Not Available') FROM employees; SELECT NVL2(commission_pct, TO_CHAR(commission_pct * .15), 'Not Available') FROM employees; Correct answers: C, E
upvoted 1 times
...
ama
3 years, 10 months ago
C , D are corrects!
upvoted 1 times
amorimleandro
3 years, 10 months ago
Nope, C, E are correct. You cannot convert all the function NVL in D, because its result is an error. But, in E, we have a similar situation as in C.
upvoted 2 times
...
LrnsTgh
2 years, 8 months ago
D has no different with A. they aren't correct.
upvoted 1 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 ...