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.
- 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 → - 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 →
Attempt
Write a query or design from the brief before opening any hints.
Validate
Run it against the included dataset and inspect the output.
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
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.