Skip to main contentSkip to solution

State the correct output of the following command.

SELECT SUBSTR('NTA CUET 2025',3,-2);

Solution

✅ Correct Option: 3

The syntax is SUBSTR(string,pos,len)\text{SUBSTR}(string, pos, len). It returns lenlen characters starting from position pospos, and the count always runs forward.

Here len=−2len = -2, which is less than 1, so zero characters are returned. The result is an empty string, so the query displays no output.


Options 1 and 2: a negative length does not make the function read backwards from position 3.

Option 4: a negative position counts from the end of the string, so SUBSTR(’NTA CUET 2025’,−2)\text{SUBSTR}(\text{'NTA CUET 2025'}, -2) would give 25. Here the negative value is the length, not the position.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question