Multiple choice technology databases

SELECT CONCAT(SUBSTR('MINDWORKS',-5,6),SUBSTR('KNOWMAX',-3,4)) FROM DUAL;

  1. KNOWMIND

  2. WORKSM

  3. WORKSMAX

  4. 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;
  1. 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'.
  2. 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'.
  3. 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.