Examine the structure of the SHIPMENTS table:
You want to generate a report that displays the PO_ID and the penalty amount to be paid if the
SHIPMENT_DATE is later than one month from the PO_DATE. The penalty is $20 per day.
Evaluate the following two queries:
Which statement is true regarding the above commands?
A.
Both execute successfully and give correct results.
B.
Only the first query executes successfully but gives a wrong result.
C.
Only the first query executes successfully and gives the correct result.
D.
Only the second query executes successfully but gives a wrong result.
E.
Only the second query executes successfully and gives the correct result.
Explanation:
The MONTHS_BETWEEN(date 1, date 2) function returns the number of months between two
dates:months_between(’01-FEB-2008′,’01-JAN-2008′) = 1
The DECODE Function
Although its name sounds mysterious, this function is straightforward. The DECODE function
implements if then-else conditional logic by testing its first two terms for equality and returns the
third if they are equal and optionally returns another term if they are not. DECODE Function
Facilitates conditional inquiries by doing the work of a CASE expression or an IF-THENELSE
statement:
DECODE(col|expression, search1, result1
[, search2, result2,…,]
[, default])
DECODE Function
The DECODE function decodes an expression in a way similar to the IF-THEN-ELSE logic that is
used in various languages. The DECODE function decodes expression after comparing it to each
search value. If the expression is the same as search, result is returned.
If the default value is omitted, a null value is returned where a search value does not match any of
the result values.