1Z0-071 · Question #226
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…
The correct answer is C. SELECT TO_CHAR(TO_NUMBER(prod_price,'$99,999.99')* .25,'$99,999.00') FROM PRICEJLIST. Using the TOJCHAR Function The TOJCHAR 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…
Question
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?
Options
- ASELECT TO_CHAR(prod_price* .25,'$99,999.99') FROM PRICEJJST;
- BSELECT TO_CHAR(TO_NUMBER(prod_price)* .25,'$99,999.00') FROM PRICEJLIST;
- CSELECT TO_CHAR(TO_NUMBER(prod_price,'$99,999.99')* .25,'$99,999.00') FROM PRICEJLIST;
- DSELECT TO_NUMBER(TO_NUMBER(prod_price,'$99,999.99')* .25,'$99,999.00') FROM
How the community answered
(23 responses)- A9% (2)
- B13% (3)
- C74% (17)
- D4% (1)
Explanation
Using the TOJCHAR Function The TOJCHAR 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
Topics
Community Discussion
No community discussion yet for this question.