SELECT CONCAT(SUBSTR('MINDWORKS',-5,6),SUBSTR('KNOWMAX',-3,4)) FROM DUAL;
-
KNOWMIND
-
WORKSM
-
WORKSMAX
-
MAXWORKS
Reveal answer
Fill a bubble to check yourself
C
Correct answer
Explanation
In Oracle SQL, SUBSTR with a negative index counts backward from the end of the string. SUBSTR('MINDWORKS',-5,6) starts at 'W' and returns 'WORKS'. SUBSTR('KNOWMAX',-3,4) starts at 'M' and returns 'MAX'. Concatenating these results yields 'WORKSMAX'.
AI explanation
To answer this question, let's break down the query step by step:
The given query is:
SELECT CONCAT(SUBSTR('MINDWORKS',-5,6),SUBSTR('KNOWMAX',-3,4)) FROM DUAL;
SUBSTR('MINDWORKS',-5,6):- This function extracts a substring from the string 'MINDWORKS'.
- The starting point (-5) specifies that the substring should start from the 5th character from the end of the string.
- The length (6) specifies that the substring should have a length of 6 characters.
- Therefore, this expression returns 'WORKS'.
SUBSTR('KNOWMAX',-3,4):- This function extracts a substring from the string 'KNOWMAX'.
- The starting point (-3) specifies that the substring should start from the 3rd character from the end of the string.
- The length (4) specifies that the substring should have a length of 4 characters.
- Therefore, this expression returns 'MAX'.
CONCAT(SUBSTR('MINDWORKS',-5,6),SUBSTR('KNOWMAX',-3,4)):- This function concatenates the two substrings obtained from the previous steps.
- The result of the concatenation is 'WORKSMAX'.
Therefore, the correct answer is option C) WORKSMAX.