What is the correct output of the above query?

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

Discussion

3 Responses to “What is the correct output of the above query?”

  1. Ivan Ticona says:

    Could someone explain why this, please!

  2. Justyna says:

    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

  3. Ivan says:

    Thaks Justina, today I will give my exam.

Leave a Reply