QuestionQ100

VerifiedUsing Conversion Functions and Conditional Expressions

Refer to the exhibit and review the structure of the customers table.

Question Image

Using the customers table, generate a report that displays a 15% increase in the credit limit for every customer. For customers whose credit limit was not entered, display the message "Not Available."

Which SQL statement produces the required result?

Question Image

Explanation

CUST_CREDIT_LIMIT * .15 produces a numeric value, while Not Available is character text. Converting the numeric calculation with TO_CHAR before applying NVL makes both possible return values character data, allowing NVL to display the calculation for non-null values and Not Available for null values. Oracle documents this same pattern: use NVL(TO_CHAR(numeric_expression), character_replacement) when substituting text for a null numeric result.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!