Challenge - 5 Problems
String Function Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Using LOWER() to find case-insensitive matches
Given a table Users with a column
username, which query returns all users whose username is 'alice' regardless of case?SQL
SELECT username FROM Users WHERE LOWER(username) = 'alice';
Attempts:
2 left
💡 Hint
Think about how to ignore uppercase or lowercase differences in text.
✗ Incorrect
The LOWER() function converts all characters to lowercase, so comparing LOWER(username) to 'alice' finds matches regardless of original case.
❓ query_result
intermediate2:00remaining
Extracting domain from email using SUBSTRING and POSITION
Which query correctly extracts the domain part (after '@') from the
email column in the Contacts table?SQL
SELECT SUBSTRING(email FROM POSITION('@' IN email) + 1) AS domain FROM Contacts;
Attempts:
2 left
💡 Hint
Remember that POSITION('@' IN email) gives the location of '@'.
✗ Incorrect
Option D extracts substring starting right after '@' to the end, which is the domain part.
📝 Syntax
advanced2:00remaining
Identifying syntax error in string concatenation
Which option contains a syntax error when trying to concatenate first and last names with a space in between in SQL?
Attempts:
2 left
💡 Hint
Check which operator is valid for string concatenation in SQL.
✗ Incorrect
Option C uses '+' which is invalid for string concatenation in standard SQL, causing a syntax error.
❓ optimization
advanced2:00remaining
Optimizing query with TRIM to remove spaces
Which query efficiently removes leading and trailing spaces from the
product_code column in the Inventory table before comparison?Attempts:
2 left
💡 Hint
Consider which side the spaces might be on and how to remove them from the column data.
✗ Incorrect
Option A trims spaces from the column value before comparing, ensuring correct matches even if data has spaces.
🧠 Conceptual
expert2:00remaining
Why use string functions in queries?
Which reason best explains why string functions are important in database queries?
Attempts:
2 left
💡 Hint
Think about what string functions do to text data in queries.
✗ Incorrect
String functions help clean, compare, and extract parts of text data, making queries more flexible and accurate.