Standardize Mixed-Case Names
Return each record_id with first_name uppercased and last_name lowercased.
- String functions
- Sorting
Exercise brief
Understand the request
Identity data steward A downstream matching job needs predictable name casing without changing the stored source values.
A downstream matching job needs predictable name casing without changing the stored source values. Return each record_id with first_name uppercased and last_name lowercased.
Return
- Alias the derived columns as normalized_first_name and normalized_last_name.
- Order by record_id ascending.
Constraints
- Use both UPPER and LOWER.
- Preserve NULL last names as NULL.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
function_cases
record_idINTEGERfirst_nameTEXTlast_nameTEXTlabelTEXTemailTEXTbackup_emailTEXTphoneTEXTraw_unitsTEXTraw_quantityTEXTraw_statusTEXTactual_valueREALtarget_valueREALcompleted_unitsREALelapsed_hoursREAL
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Case functions transform their input expression but do not update the table.
Hint 2
NULL passed to a scalar string function remains NULL.
Hint 3
Project UPPER(first_name) and LOWER(last_name), then order by record_id.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT record_id, UPPER(first_name) AS normalized_first_name, LOWER(last_name) AS normalized_last_name FROM function_cases ORDER BY record_id;Why this works
UPPER and LOWER are row-level transformations. Keeping the raw columns unchanged while deriving normalized output is a common staging and matching pattern.
Success check
All eight records are returned in stable order with the requested case transformations.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| record_id | normalized_first_name | normalized_last_name |
|---|---|---|
| 101 | ALICE | ng |
| 102 | BOB | NULL |
| 103 | CAROL | o'neil |
| 104 | DAVE | smith |
| 105 | EVE | li |
| 106 | FRANK | miller |
| 107 | GRACE | kim |
| 108 | HEIDI | brown |
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.