Challenge - 5 Problems
UPPER and LOWER Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this query using UPPER?
Consider a table Employees with a column first_name containing the value 'Alice'. What will be the result of this query?
SELECT UPPER(first_name) AS upper_name FROM Employees WHERE first_name = 'Alice';
SQL
SELECT UPPER(first_name) AS upper_name FROM Employees WHERE first_name = 'Alice';
Attempts:
2 left
💡 Hint
UPPER converts all letters to uppercase.
✗ Incorrect
The UPPER function changes all letters in the string to uppercase. Since the original name is 'Alice', the output is 'ALICE'.
❓ query_result
intermediate2:00remaining
What does LOWER return for mixed case input?
Given a table Products with a column product_code containing 'XyZ123', what is the output of:
SELECT LOWER(product_code) AS lower_code FROM Products WHERE product_code = 'XyZ123';
SQL
SELECT LOWER(product_code) AS lower_code FROM Products WHERE product_code = 'XyZ123';
Attempts:
2 left
💡 Hint
LOWER converts all letters to lowercase.
✗ Incorrect
LOWER changes all letters to lowercase. The digits remain unchanged. So 'XyZ123' becomes 'xyz123'.
📝 Syntax
advanced2:00remaining
Which query correctly converts names to uppercase?
You want to select all names from the Users table and convert them to uppercase. Which query is syntactically correct?
Attempts:
2 left
💡 Hint
Function calls require parentheses around arguments.
✗ Incorrect
Option A uses correct syntax with UPPER function and parentheses. Option A misses semicolon but is often accepted; however, standard SQL requires semicolon. Option A misses parentheses. Option A has misplaced parentheses.
❓ optimization
advanced2:00remaining
Which query is more efficient to find names ignoring case?
You want to find all rows where the username is 'admin'. Which query is more efficient on a large table with an index on username?
Attempts:
2 left
💡 Hint
Using functions on indexed columns can prevent index use.
✗ Incorrect
Applying LOWER or UPPER on the column disables index use, causing full scan. Direct comparison (option C) uses index if case matches. Option C (ILIKE) is case-insensitive but may not use index depending on DBMS.
🧠 Conceptual
expert2:00remaining
Why might UPPER and LOWER produce unexpected results with accented letters?
In some databases, using UPPER or LOWER on strings with accented characters (like 'é' or 'ß') may not convert as expected. Why does this happen?
Attempts:
2 left
💡 Hint
Think about how databases handle language and character encoding.
✗ Incorrect
Case conversion depends on collation and character set settings. Some collations treat accented letters differently, affecting UPPER and LOWER results.