Sail E0 Webinar
Question
The SQL statement
SELECT SUBSTR('123456789', INSTR('abcabcabc', 'b'), 4) FROM DUAL;
Options:
A .  6789
B .  2345
C .  1234
D .  456789
Answer: Option B
Answer: B. 2345

Explanation: The INSTR() function is used to find the first occurrence of a substring in a string. The syntax for INSTR() is INSTR(string, substring). In this question, the INSTR() function is used to find the first occurrence of the substring 'b' in the string 'abcabcabc'. The INSTR() function returns the position of the first occurrence of the substring, which is 2.

The SUBSTR() function is used to extract a substring from a given string. The syntax for SUBSTR() is SUBSTR(string, start_position, [length]). In this question, the SUBSTR() function is used to extract a substring from the string '123456789' starting at the position 2 and with a length of 4. Therefore, the output of the query is '2345'.

Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers