nerdexam
Oracle

1Z0-061 · Question #151

Examine the structure of the INVOICE table: Which two SQL statements would execute successfully? (Choose two.)

The correct answer is A. SELECT inv_no, NVL2(inv_date, 'Pending', 'Incomplete') C. SELECT inv_no, NVL2(inv_date, sysdate-inv_date, sysdate). The NVL2 Function The NVL2 function provides an enhancement to NVL but serves a very similar purpose. It evaluates whether a column or expression of any data type is null or not. 5-6 The NVL function\ If the first term is not null, the second parameter is returned, else the…

Using Single-Row Functions to Customize Output

Question

Examine the structure of the INVOICE table:

Which two SQL statements would execute successfully? (Choose two.)

Options

  • ASELECT inv_no, NVL2(inv_date, 'Pending', 'Incomplete')
  • BSELECT inv_no, NVL2(inv_amt, inv_date, 'Not Available')
  • CSELECT inv_no, NVL2(inv_date, sysdate-inv_date, sysdate)
  • DSELECT inv_no, NVL2(inv_amt, inv_amt*.25, 'Not Available')

How the community answered

(36 responses)
  • A
    72% (26)
  • B
    11% (4)
  • D
    17% (6)

Explanation

The NVL2 Function The NVL2 function provides an enhancement to NVL but serves a very similar purpose. It evaluates whether a column or expression of any data type is null or not. 5-6 The NVL function\ If the first term is not null, the second parameter is returned, else the third parameter is returned. Recall that the NVL function is different since it returns the original term if it is not null. The NVL2 function takes three mandatory parameters. Its syntax is NVL2(original, ifnotnull, ifnull), where original represents the term being tested. Ifnotnull is returned if original is not null, and ifnull is returned if original is null. The data types of the ifnotnull and ifnull parameters must be compatible, and they cannot be of type LONG. They must either be of the same type, or it must be possible to convert ifnull to the type of the ifnotnull parameter. The data type returned by the NVL2 function is the same as that of the ifnotnull parameter.

Topics

#NVL2#NULL handling#data type compatibility#single-row functions

Community Discussion

No community discussion yet for this question.

Full 1Z0-061 Practice