Which of the following SELECT statements will get the result 'elloworld' from the string 'HelloWorld'?

  1. SELECT SUBSTR ('HelloWorld',1) FROM dual;

  2. SELECT LOWER (SUBSTR ('HellowWorld', 2,1) FROM dual;

  3. SELECT LOWER (SUBSTR('HellowWorld', 2,1) FROM dual;

  4. SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual;


Correct Option: D

AI Explanation

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

Option A) SELECT SUBSTR ('HelloWorld',1) FROM dual; This option selects a substring from the string 'HelloWorld' starting from the first character. So, the result will be 'H'. This option is incorrect.

Option B) SELECT LOWER (SUBSTR ('HellowWorld', 2,1) FROM dual; This option selects a substring from the string 'HellowWorld' starting from the second character and with a length of 1. The result will be 'e'. This option is incorrect.

Option C) SELECT LOWER (SUBSTR('HellowWorld', 2,1) FROM dual; This option is the same as option B, with a minor typo in the spelling of 'HelloWorld'. The result will also be 'e'. This option is incorrect.

Option D) SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual; This option trims the character 'H' from the string 'Hello World', resulting in 'ello World'. Then, it converts the remaining string to lowercase using the LOWER function. The final result will be 'elloworld'. This option is correct.

The correct answer is D. This option is correct because it trims the 'H' from the string and converts the remaining string to lowercase, resulting in 'elloworld'.

Find more quizzes: