Match Imported Names Across Letter Case
Find every contact matching ALICE JOHNSON regardless of letter case.
- String functions
- Filtering
- Sorting
Exercise brief
Understand the request
Identity data analyst An imported full name may use different letter casing than the contact directory.
Return every contact whose display name matches ALICE JOHNSON regardless of letter case.
Return
- Return contact_id, display_name in this exact left-to-right order.
Constraints
- Normalize both full-name operands to the same case before comparing them for equality.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
contact_records
contact_idINTEGERdisplay_nameVARCHAR(100)
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Normalize both full-name values to the same case before comparing them.
Hint 2
Apply `LOWER()` to display_name and to the imported search value, then use equality.
Hint 3
SELECT contact_id, display_name FROM contact_records WHERE LOWER(display_name) = LOWER(/* imported full name */) ORDER BY contact_id;
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT contact_id, display_name FROM contact_records WHERE LOWER(display_name) = LOWER('ALICE JOHNSON') ORDER BY contact_id;Why this works
The fixture stores the same full name in title case, uppercase, lowercase, and mixed case, plus a similar but different name. Normalizing both operands makes all four true matches observable and prevents ordinary equality from passing under a case-sensitive engine. Unicode case folding and locale-specific rules can still vary, and applying a function to the column may require a functional index for scale. PostgreSQL is case-sensitive by default, while SQLite, MySQL, and SQL Server behavior also depends on operator and collation.
Success check
All casing variants of the exact full name are returned, while similar names remain excluded.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| contact_id | display_name |
|---|---|
| 1 | Alice Johnson |
| 2 | ALICE JOHNSON |
| 3 | alice johnson |
| 7 | ALIce JoHnson |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
SELECT Statements
Select columns, filter rows, remove duplicates, and order query results.
CASE Statements & Conditional Logic
Build NULL-aware classifications, precedence-safe decisions, flags, scores, and guarded calculations with portable CASE expressions.
Date Operations & Time-Based Analytics
Practice date arithmetic, safe timestamp ranges, calendar bucketing, dense time series, rolling windows, growth, and cohort analysis.
Open the interactive workspace and practice across SQL topics.