SQL Data Analytics • Lesson 12

String Functions

Learn how SQL cleans, transforms, measures and analyzes text stored inside database columns.

Your progress0%

0 of 8 concepts completed

Complete the activity and related MCQ to unlock the next concept.

Concept 1WHY STRINGS

Why Analysts Need String Functions

Names arrive with extra spaces, cities use mixed capitalization, emails are inconsistent. String functions clean, transform and analyze that text before it reaches a report.

Interactive Data

Raw vs Clean

The same four customer rows before and after applying TRIM, UPPER and LOWER. Quotes mark the exact stored value — extra spaces are visible inside the quotes.

4
ROWS
3
TEXT COLUMNS
7
FUNCTIONS

Before

namecityemail
" Rahul Sharma ""dehradun""RAHUL@EMAIL.COM"
"Priya Singh""MUMBAI""priya@email.com"
" Amit Kumar""Delhi""AMIT@EMAIL.COM"
"Neha Verma ""Pune""neha@email.com"

After TRIM / UPPER / LOWER

clean_nameclean_cityclean_email
Rahul SharmaDEHRADUNrahul@email.com
Priya SinghMUMBAIpriya@email.com
Amit KumarDELHIamit@email.com
Neha VermaPUNEneha@email.com

Learn by Seeing

Three jobs for string functions

CLEAN     → remove spaces, fix case
TRANSFORM → rename, replace, combine
ANALYZE   → measure, extract parts

Almost every string transformation falls into one of these three categories.

Click a category to explore what string functions do:

CLEAN

Remove invisible spaces and fix inconsistent capitalization so equal values actually match.

"  delhi "  →  TRIM + UPPER  →  "DELHI"

Interactive Activity

Which of these best describes why string functions matter?

Hint: Think about 'delhi' vs 'DELHI' in a grouping query.

SQL Analyst Mindset

Text is data too

Most datasets are more than half text. Cleaning and standardizing text with string functions is what makes joins, groupings and filters actually work as intended.

01

Inspect

Look for spaces, mixed case, separators.

02

Standardize

TRIM, UPPER, LOWER.

03

Reshape

CONCAT, REPLACE, LEFT, RIGHT.

04

Validate

Does the cleaned text group correctly?

Frequently Asked Questions

SQL String Functions — FAQs

Does TRIM remove spaces inside a string?

No. TRIM only removes leading and trailing spaces — spaces between words are preserved.

Does LENGTH count spaces?

Yes. LENGTH counts every character, including spaces and punctuation.

Is CONCAT the same as using the + operator?

Similar idea, but CONCAT is the standard, portable function across most SQL databases and handles NULLs more gracefully.

Does REPLACE change the original table?

No. REPLACE only changes the value in the query result — the underlying stored data stays untouched unless you run an UPDATE.

Lesson Summary

What you learned

UPPER() / LOWER()

Standardize capitalization.

TRIM()

Remove leading and trailing spaces.

LENGTH()

Measure the number of characters.

LEFT() / RIGHT() / CONCAT() / REPLACE()

Extract, combine and substitute text values.