State the output of the following query:
SELECT LEFT(RTRIM('$$PYTHON$$'),4);
WHERE '$' REPRESENTS BLANK SPACE.
State the output of the following query:
SELECT LEFT(RTRIM('$$PYTHON$$'),4);
WHERE '$' REPRESENTS BLANK SPACE.
Solution
✅ Correct Option: 1
RTRIM removes only the trailing blank spaces on the right. So $$PYTHON$$ becomes $$PYTHON, with the two leading spaces kept.
LEFT(string, 4) then returns the first 4 characters: two spaces, P and Y, which gives $$PY.
Option 2: this would need the leading spaces removed too (LTRIM or TRIM), but RTRIM does not touch the left side.
Options 3 and 4: these come from RIGHT, not LEFT. RIGHT on the original string gives ON$$, and RIGHT after RTRIM gives THON.
Related questions:
2026: 18 May Shift 2
2026: 26 May Shift 1