Which SELECT statement will get the result 'elloworld' from the string 'HelloWorld'?

  1. SELECT INITCAP(TRIM ('HelloWorld', 1,1)) FROM dual;

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

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

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


Correct Option: D
Explanation:

To solve this question, the user needs to know the basics of SQL SELECT statements and string manipulation functions. The user should be familiar with the INITCAP, TRIM, SUBSTR, and LOWER functions.

Now, let's go through each option and explain why it is right or wrong:

A. SELECT INITCAP(TRIM ('HelloWorld', 1,1)) FROM dual;

This option is incorrect. The TRIM function removes characters from the beginning and end of a string. In this case, the second and third arguments of the TRIM function are incorrect. INITCAP capitalizes the first letter of a string and converts the rest of the string to lowercase. Therefore, this SELECT statement will not return the correct result.

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

This option is incorrect. The SUBSTR function returns a substring from a given string. In this case, the function only returns the first character of the string 'HelloWorld'. Therefore, this SELECT statement will not return the correct result.

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

This option is incorrect. The SUBSTR function returns a substring from a given string. In this case, the function only returns the first character of the string 'HelloWorld'. The LOWER function converts the substring to lowercase. Therefore, this SELECT statement will not return the correct result.

D. SELECT LOWER(TRIM ('H' FROM 'HelloWorld')) FROM dual;

This option is correct. The TRIM function removes the character 'H' from the beginning of the string 'HelloWorld'. The LOWER function converts the remaining string to lowercase. Therefore, this SELECT statement will return the correct result.

The Answer is: D

Find more quizzes: