Which four statements correctly describe functions that are available in SQL? (Choose four)

  1. INSTR returns the numeric position of a named character.

  2. NVL2 returns the first non-null expression in the expression list.

  3. DECODE translates an expression after comparing it to each search value

  4. TRIM trims the heading of trailing characters (or both) from a character string

  5. NVL compares two expressions and returns null if they are equal, or the first expression of they are not equal

  6. NULLIF compares twp expressions and returns null if they are equal, or the first expression if they are not equal


Correct Option: A,C,D,F

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) INSTR returns the numeric position of a named character - This option is correct because the INSTR function in SQL returns the position of a specified character or substring within a string.

Option B) NVL2 returns the first non-null expression in the expression list - This option is incorrect because the NVL2 function in SQL returns the second expression if the first expression is not null, otherwise it returns the third expression.

Option C) DECODE translates an expression after comparing it to each search value - This option is correct because the DECODE function in SQL compares an expression to a list of search values and returns a result based on the matching value.

Option D) TRIM trims the heading or trailing characters (or both) from a character string - This option is correct because the TRIM function in SQL removes leading and/or trailing characters (or both) from a character string.

Option E) NVL compares two expressions and returns null if they are equal, or the first expression if they are not equal - This option is incorrect because the NVL function in SQL compares an expression to null and returns a specified value if the expression is null, otherwise it returns the expression itself.

Option F) NULLIF compares two expressions and returns null if they are equal, or the first expression if they are not equal - This option is correct because the NULLIF function in SQL compares two expressions and returns null if they are equal, otherwise it returns the first expression.

The correct answers are A, C, D, and F.

Find more quizzes: