SQL Topic collection

Basic SQL Functions SQL Topic exercises

Practice production-oriented string cleanup, numeric transformations, NULL handling, tolerant conversion, and delimiter parsing.

Exercises
13
Difficulty
Beginner to Advanced

What this collection tests

Skills and query patterns

UPPER, LOWER, character length, substring, concatenation, TRIM, REPLACE, ROUND, ABS, COALESCE, NULLIF, safe CAST patterns, and modulo

Curated exercises

Choose an exercise

Work in the live editor where supported. Advanced guided labs state their engine boundary before you open the workspace.

  1. Exercise 1Easy

    Standardize Mixed-Case Names

    Return each record_id with first_name uppercased and last_name lowercased.

    • String functions
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  2. Exercise 2Easy

    Measure Unicode Labels by Character

    Return each record_id, label, and the trimmed label character count.

    • String functions
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  3. Exercise 3Easy

    Use SUBSTRING for a Fixed-Width Batch Prefix

    Return record_id, raw_units, and its first two characters as batch_prefix.

    • String functions
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  4. Exercise 4Medium

    Build a Null-Safe Display Name

    Build display_name from lowercase first_name and last_name, using 'unknown' for a NULL last_name.

    • String functions
    • NULL handling
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  5. Exercise 5Easy

    Find and Trim Padded Emails

    Return records whose non-NULL email changes when trimmed.

    • String functions
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  6. Exercise 6Medium

    Normalize Mixed Phone Punctuation

    Remove plus signs, parentheses, spaces, dots, and dashes from each non-NULL phone.

    • String functions
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  7. Exercise 7Easy

    Round a Completion Percentage

    Calculate completion_pct as actual_value divided by target_value times 100.

    • Numeric functions
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  8. Exercise 8Medium

    Rank Absolute Target Deviations

    Calculate absolute_deviation as the absolute difference between actual_value and target_value.

    • Numeric functions
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  9. Exercise 9Medium

    Choose the First Usable Contact

    Return the first nonblank trimmed email, or 'unreachable' when neither address is usable.

    • String functions
    • NULL handling
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  10. Exercise 10Medium

    Calculate a Divide-by-Zero-Safe Rate

    Calculate units_per_hour, rounded to two decimals, using NULL for zero elapsed_hours.

    • Numeric functions
    • NULL handling
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  11. Exercise 11Medium

    Safely Convert Dirty Quantity Text

    Convert valid raw_quantity values to integers and return NULL for values that cannot be converted.

    • CASE expressions
    • String functions
    • Type conversion

    SQLite + PostgreSQL live · 3 guided

    Open exercise
  12. Exercise 12Medium

    Assign Deterministic Modulo Shards

    Calculate shard_id as the remainder of record_id divided by four.

    • CASE expressions
    • Numeric functions
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
  13. Exercise 13Medium

    Parse Valid Email Components

    Split trimmed emails containing '@' into lowercase local_part and domain columns.

    • String functions
    • Filtering
    • Sorting

    SQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

    Open exercise
01

Attempt

Write a query or design from the brief before opening any hints.

02

Validate

Run it against the included dataset and inspect the output.

03

Explain

Compare the verified answer and explain each choice aloud.

Learn before practicing Basic SQL Functions

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.