Basic SQL Functions SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

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_idINTEGER
  • first_nameTEXT
  • last_nameTEXT
  • labelTEXT
  • emailTEXT
  • backup_emailTEXT
  • phoneTEXT
  • raw_unitsTEXT
  • raw_quantityTEXT
  • raw_statusTEXT
  • actual_valueREAL
  • target_valueREAL
  • completed_unitsREAL
  • elapsed_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_idnormalized_first_namenormalized_last_name
101ALICEng
102BOBNULL
103CAROLo'neil
104DAVEsmith
105EVEli
106FRANKmiller
107GRACEkim
108HEIDIbrown

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.