Before you start, you need
Transform or measure a text
A report may need categories in upper case or names in lower case. A function takes a value and returns another. For example, UPPER(category) takes a product's category and returns its upper-case version.
UPPER converts to upper case and LOWER to lower case. LENGTH counts characters: LENGTH('SQL') returns 3. Write the value or the column in parentheses after the name of the function.
When you apply a function to a column, the calculation is done for each row. You can keep the product name and show its transformed category next to it.
The function in SELECT does not change the stored text. Use an alias to explain the new column, such as AS label. Joining text with || has its own lesson straight after this one, and dates are covered in the one after that. A word of warning: in SQLite, UPPER and LOWER only the unaccented letters change, so Martín becomes MARTíN. It is not your mistake.
SELECT LOWER(name) AS name_lowercase
FROM employees;See it in action
We want to show the categories in upper case.
SELECT name, UPPER(category) AS label
FROM products;| name | label |
|---|---|
| Mouse | ACCESSORIES |
| Keyboard | ACCESSORIES |
| Monitor 24 | DISPLAYS |
| Pro Laptop | COMPUTERS |
| Headphones | AUDIO |
| Monitor 27 | DISPLAYS |
| SSD Drive | STORAGE |
| Cable USB-C | ACCESSORIES |
- UPPER takes each product's category and returns it in upper case.
- AS label gives the calculated value a heading. The stored name and category stay as they are.
- LOWER does the reverse presentation change and LENGTH measures characters. The challenge combines both decisions without changing the data.
- For accents and other characters, check the result on the engine you are using; do not assume every engine converts them the same way.
Practice with help
Getting things wrong is part of learning: you can run your query as many times as you like and nothing is lost. If you get stuck, open a hint (each one reveals a bit more) and save the solution for last.
Guided practice
Show names in lower case
Write a query that returns each employee's name in lower case as name_lowercase, together with their joined_at.
Expected result: 10 rows with the columns name_lowercase, joined_at, in that order. Row order does not matter.
View tables and data
Open this panel to see the full data.
Change how name is presented to lower case and keep joined_at as it is.
Add a descriptive alias.
Select joined_at as well.
Solution explained
SELECT LOWER(name) AS name_lowercase, joined_at FROM employees;LOWER changes only the query result.
Your turn
Solve this variation. Spot the part that has changed before you look for help.
Practice
Build a label
Show UPPER(category) as label and LENGTH(category) as characters for each product. Keep every row.
Expected result: 9 rows with the columns label, characters, in that order. Row order does not matter.
View tables and data
Open this panel to see the full data.
You need two values calculated from the same attribute.
One function changes the presentation and the other counts characters.
Apply UPPER and LENGTH to category and use the aliases label and characters.
Solution explained
SELECT UPPER(category) AS label, LENGTH(category) AS characters FROM products;Each product keeps its row. label changes the presentation and characters measures the length of the text.
Key takeaways
- LOWER and UPPER change how text is presented.
- LENGTH counts characters.
- Functions in SELECT leave the source unchanged.
Go deeper
In standard SQLite, UPPER and LOWER convert ASCII letters and may leave accented letters unchanged. LENGTH counts characters, not bytes. The lab is a teaching tool: check formats and characters before moving a transformation to another engine.