1Z0-007 · Question #143
The EMPLOYEE tables have these columns: You want to display the name and annual salary multiplied by the commission_pct for all employees. For records that have a NULL commission_pct, a zero must be…
The correct answer is D. SELECT last_name, (salary * 12) * NVL(commission_pct, 0) FROM EMPLOYEES. This SELECT statement provides correct usage of NVL function to calculate columns for all employees. Oracle give you possibility to substitute a value in place of NULL. The basic syntax for NVL() is NVL(column_name, value_if_null). Notice that the column specified in NVL()…
Question
The EMPLOYEE tables have these columns:
You want to display the name and annual salary multiplied by the commission_pct for all employees. For records that have a NULL commission_pct, a zero must be displayed against the calculated column. Which SQL statement displays the desired results?
Options
- ASELECT last_name, (salary * 12) * commission_pct FROM EMPLOYEES;
- BSELECT last_name, (salary * 12) * IFNULL(commission_pct, 0) FROM EMPLOYEES;
- CSELECT last_name, (salary * 12) * NVL2(commission_pct, 0) FROM EMPLOYEES;
- DSELECT last_name, (salary * 12) * NVL(commission_pct, 0) FROM EMPLOYEES;
How the community answered
(30 responses)- A13% (4)
- B7% (2)
- C3% (1)
- D77% (23)
Explanation
This SELECT statement provides correct usage of NVL function to calculate columns for all employees. Oracle give you possibility to substitute a value in place of NULL. The basic syntax for NVL() is NVL(column_name, value_if_null). Notice that the column specified in NVL() contains an actual value. That value is what Oracle returns; when the column is NULL, the special string isreturned. The value specified to be returned if the column value is NULL must be the same datatype as the column specified. Incorrect Answers A: This SELECT statement will return NULL value for rows with NULL COMMISION_PCT B: There is no IFNULL() function in Oracle. C: The NVL2() function requires 3 parameters, not 2. Function NVL2(expr1, expr2, expr3) returns expr2 if expr1 is not NULL. If expr1 is NULL, it
Topics
Community Discussion
No community discussion yet for this question.