Challenge - 5 Problems
Trim Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of TRIM removing spaces
What is the output of the following SQL query?
SELECT TRIM(' hello world ') AS trimmed_text;SQL
SELECT TRIM(' hello world ') AS trimmed_text;
Attempts:
2 left
💡 Hint
TRIM removes spaces from both the start and end of the string.
✗ Incorrect
The TRIM function removes all leading and trailing spaces from the string, so the output is 'hello world' without spaces on either side.
❓ query_result
intermediate2:00remaining
Output of LTRIM removing leading spaces
What is the output of this SQL query?
SELECT LTRIM(' data science ') AS left_trimmed;SQL
SELECT LTRIM(' data science ') AS left_trimmed;
Attempts:
2 left
💡 Hint
LTRIM removes spaces only from the start of the string.
✗ Incorrect
LTRIM removes spaces from the left side only, so trailing spaces remain intact.
❓ query_result
advanced2:00remaining
Output of RTRIM removing trailing spaces
What does this SQL query return?
SELECT RTRIM(' database ') AS right_trimmed;SQL
SELECT RTRIM(' database ') AS right_trimmed;
Attempts:
2 left
💡 Hint
RTRIM removes spaces only from the end of the string.
✗ Incorrect
RTRIM removes trailing spaces, so leading spaces remain but trailing spaces are removed.
🧠 Conceptual
advanced2:00remaining
Difference between TRIM, LTRIM, and RTRIM
Which statement correctly describes the difference between TRIM, LTRIM, and RTRIM functions in SQL?
Attempts:
2 left
💡 Hint
Think about which side each function trims spaces from.
✗ Incorrect
TRIM removes spaces from both the start and end of a string. LTRIM removes spaces only from the start (left side). RTRIM removes spaces only from the end (right side).
📝 Syntax
expert2:00remaining
Identify the syntax error in TRIM usage
Which option will cause a syntax error when trying to remove leading and trailing spaces from the string ' example ' in standard SQL?
Attempts:
2 left
💡 Hint
Check the correct syntax for specifying which characters to trim in TRIM function.
✗ Incorrect
Option C is missing the characters to trim after BOTH keyword, causing a syntax error. The correct syntax requires specifying the characters to trim, e.g., TRIM(BOTH ' ' FROM string).