0
0
SQLquery~20 mins

Why string functions matter in queries in SQL - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
String Function Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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';
ASELECT username FROM Users WHERE LOWER(username) = 'alice';
BSELECT username FROM Users WHERE username LIKE 'Alice';
CSELECT username FROM Users WHERE UPPER(username) = 'ALICE';
DSELECT username FROM Users WHERE username = 'alice';
Attempts:
2 left
💡 Hint
Think about how to ignore uppercase or lowercase differences in text.
query_result
intermediate
2: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;
ASELECT SUBSTRING(email, 1, POSITION('@' IN email) - 1) AS domain FROM Contacts;
BSELECT SUBSTRING(email, POSITION('@' IN email)) AS domain FROM Contacts;
CSELECT SUBSTRING(email FROM 1 FOR POSITION('@' IN email)) AS domain FROM Contacts;
DSELECT SUBSTRING(email FROM POSITION('@' IN email) + 1) AS domain FROM Contacts;
Attempts:
2 left
💡 Hint
Remember that POSITION('@' IN email) gives the location of '@'.
📝 Syntax
advanced
2: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?
ASELECT first_name || ' ' || last_name AS full_name FROM Employees;
BSELECT first_name || ' ' || last_name FROM Employees;
CSELECT first_name + ' ' + last_name AS full_name FROM Employees;
DSELECT CONCAT(first_name, ' ', last_name) AS full_name FROM Employees;
Attempts:
2 left
💡 Hint
Check which operator is valid for string concatenation in SQL.
optimization
advanced
2: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?
ASELECT * FROM Inventory WHERE TRIM(product_code) = 'ABC123';
BSELECT * FROM Inventory WHERE product_code = TRIM(' ABC123 ');
CSELECT * FROM Inventory WHERE product_code = 'ABC123';
DSELECT * FROM Inventory WHERE LTRIM(RTRIM(product_code)) = 'ABC123';
Attempts:
2 left
💡 Hint
Consider which side the spaces might be on and how to remove them from the column data.
🧠 Conceptual
expert
2:00remaining
Why use string functions in queries?
Which reason best explains why string functions are important in database queries?
AThey speed up database hardware performance automatically.
BThey allow manipulation and comparison of text data to handle variations and extract useful parts.
CThey replace the need for indexing tables.
DThey convert all data types into strings for easier storage.
Attempts:
2 left
💡 Hint
Think about what string functions do to text data in queries.