Challenge - 5 Problems
Trim Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of TRIM with both leading and trailing characters
What is the output of the following SQL query?
SELECT TRIM(BOTH 'x' FROM 'xxhelloxx');PostgreSQL
SELECT TRIM(BOTH 'x' FROM 'xxhelloxx');
Attempts:
2 left
💡 Hint
TRIM removes specified characters from both ends of the string.
✗ Incorrect
TRIM(BOTH 'x' FROM 'xxhelloxx') removes all 'x' characters from the start and end, leaving 'hello'.
❓ query_result
intermediate2:00remaining
Result of LTRIM removing multiple characters
What is the result of this query?
SELECT LTRIM('abc123abc', 'abc');PostgreSQL
SELECT LTRIM('abc123abc', 'abc');
Attempts:
2 left
💡 Hint
LTRIM removes all characters in the set from the start until a character not in the set is found.
✗ Incorrect
LTRIM removes all leading 'a', 'b', and 'c' characters from the start, stopping at '1'. So the result is '123abc'.
📝 Syntax
advanced2:00remaining
Identify the syntax error in RTRIM usage
Which option contains a syntax error when trying to remove trailing spaces using RTRIM in PostgreSQL?
Attempts:
2 left
💡 Hint
The characters to remove cannot be an empty string.
✗ Incorrect
RTRIM with an empty string as the second argument is invalid syntax in PostgreSQL and causes an error.
❓ query_result
advanced2:00remaining
Effect of TRIM with no characters specified
What is the output of this query?
Note: No characters specified after TRIM.
SELECT TRIM(' hello ');Note: No characters specified after TRIM.
PostgreSQL
SELECT TRIM(' hello ');
Attempts:
2 left
💡 Hint
When no characters are specified, TRIM removes spaces from both ends.
✗ Incorrect
TRIM without specifying characters removes spaces from both the start and end of the string.
🧠 Conceptual
expert3:00remaining
Understanding TRIM variations with multiple characters
Given the string 'xyxzyhellozzyx', which TRIM function call will remove all leading and trailing 'x', 'y', and 'z' characters?
Choose the correct query.
Choose the correct query.
Attempts:
2 left
💡 Hint
The order of characters in the trim set does not matter; BOTH removes from both ends.
✗ Incorrect
Option D removes all leading and trailing 'x', 'y', and 'z' characters from both ends, leaving 'hello'.