Which SQL statement returns a numeric value?
A.
SELECT ADD_MONTHS(MAX(hire_Date), 6)
FROM EMP;
B.
SELECT ROUND(hire_date)
FROM EMP;
C.
SELECT sysdate-hire_date
FROM EMP;
D.
SELECT TO_NUMBER(hire_date + 7)
FROM EMP;
Explanation:
DATE value subtract DATE value will return numeric value.
Incorrect answer:
Adoes not return numeric value
Bdoes not return numeric value
Ddoes not return numeric value
Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 9-13
select to_number(sysdate + 7) from dual;
=>
ORA-01722: invalid number
01722. 00000 – “invalid number”
*Cause:
*Action:
An error is returned for { select to_number(sysdate + 7) from dual; } because Date is not a valid input for that function. You must first explicitly cast the Date to a character using to_character() and then use a format mask in either to_number() or to_character() that results in a valid conversion from character to number.
Thank you for every other informative web site. The place else may I am getting that type of information written in such an ideal approach? I’ve a undertaking that I’m just now operating on, and I have been on the glance out for such info.|