Evaluate the following query:
SELECT INTERVAL ‘300’ MONTH,INTERVAL ’54-2′ YEAR TO MONTH,
INTERVAL ’11:12:10.1234567′ HOUR TO SECOND
FROM dual;
What is the correct output of the above query?
A.
+25-00 , +54-02, +00 11:12:10.123457
B.
+00-300, +54-02, +00 11:12:10.123457
C.
+25-00 , +00-650, +00 11:12:10.123457
D.
+00-300 , +00-650, +00 11:12:10.123457
Explanation:
Datetime Data Types
You can use several datetime data types:
INTERVAL YEAR TO MONTH
Stored as an interval of years and months
INTERVAL DAY TO SECOND
Stored as an interval of days, hours, minutes, and seconds
Justyna
September 28, 2012 at 8:50 am
INTERVAL ’300′ MONTH it is something like INTERVAL YEAR TO MONTH:
300 months is 25 years. It cannot be +00-300 because when specifying a trailing field it must be less significant than the leading field. That is way we get result 25 years 00 months.
250 months is 20 years and 10 months:
select interval ‘250’ month from dual;
INTERVAL’250’MONTH
——————
20-10
The same for INTERVAL ’54-2′ YEAR TO MONTH. Cannot be 00-650 (which is 54*12 +2) but 54-02. It is the same reason – trailing field must be less significant than the leading field.
INTERVAL ’11:12:10.1234567′ HOUR TO SECOND
it in fact
INTERVAL’11:12:10.1234567’HOURTOSECOND
————————————–
0 11:12:10.123457000
select INTERVAL ’28:12:10.1234567′ HOUR TO SECOND FROM dual;
INTERVAL’28:12:10.1234567’HOURTOSECOND
————————————–
1 4:12:10.123457000
Answer is A