Which SELECT statement will the result ‘ello world’ from the string ‘Hello World’?

  1. SELECT SUBSTR( ‘Hello World’,1) FROM dual;

  2. SELECT INITCAP(TRIM (‘Hello World’, 1,1)) FROM dual;

  3. SELECT LOWER(TRIM (‘H’ FROM ‘Hello World’)) FROM dual;

  4. SELECT LOWER(SUBSTR(‘Hello World’, 2, 1) FROM dual;


Correct Option: C
Explanation:

To solve this question, the user needs to know the basic SQL functions and how they can be applied to strings. The user must evaluate each option and determine which one will result in the desired output of 'ello world' from the given string 'Hello World'.

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

A. SELECT SUBSTR( ‘Hello World’,1) FROM dual;

This option selects a substring from the given string starting at the first character. Since the starting point is at the first character, the entire string 'Hello World' will be returned. Therefore, this option is incorrect.

B. SELECT INITCAP(TRIM (‘Hello World’, 1,1)) FROM dual;

This option capitalizes the first letter of the given string and removes any leading or trailing spaces. However, the second and third parameters of the TRIM function are invalid and will cause an error. Therefore, this option is also incorrect.

C. SELECT LOWER(TRIM (‘H’ FROM ‘Hello World’)) FROM dual;

This option removes the letter 'H' from the given string, converts it to lowercase, and removes any leading or trailing spaces. The resulting string will be 'ello world', which is the desired output. Therefore, this option is correct.

D. SELECT LOWER(SUBSTR(‘Hello World’, 2, 1) FROM dual;

This option selects a substring from the given string starting at the second character and ending after one character. The resulting substring will be 'e'. This substring is then converted to lowercase. Therefore, this option is incorrect.

The Answer is: C. SELECT LOWER(TRIM (‘H’ FROM ‘Hello World’)) FROM dual;

Find more quizzes: