Examine the structure and data in the PRIC E_LIST table: Name Null? Type
———— ————- ——————-
PROD_D NOT NULL NUMBER(3)
PROD_PRICE VARCHAR2(10)
PROD_ID PROD PRICE
———– ————————
100 $234.55
101 $6, 509.75
102 $1, 234
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 PRICEJLIST:
B.
. SELECT TO_CHAR(TO_NUMBER(prod_price)* .25.’$99.999.00′) FROM PRICE_LIST;
C.
SELECT TO_CRAR(TO_NUMBER(prod_price.’S99.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:
horrible, horrible formating and typos.
If you ignore: spaces in the values, dots instead of commas and S (which does something completely different … +/-) instead of $ in the answers, then the correct (or least wrong) answer is indeed C
SELECT TO_CRAR(TO_NUMBER(prod_price,’$99,999.99′)* .25,’$99.999.00′) FROM PRICE_LIST:
SELECT TO_CHAR(TO_NUMBER(‘$1,234.56’, ‘$99,999.99’) *.25, ‘$99,999.99’) FROM dual;
C
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;
C
Justyna
February 8, 2013 at 11:55 am
So how Oracle database knows what ‘$1,234’ means??? How to ‘understand’ the text if you do not use format in that case?