Upper case and length
An SQL exercise from Querydrill. Solve it with a SQL editor in your browser, checked on the rows it returns and again on changed data, and it is checked the moment you submit.
Try it yourself
Return each product name in upper case, together with the number of characters in the original name.
products (8 rows)
| id | name | category | price |
|---|---|---|---|
| 1 | Desk Lamp | Home | 35 |
| 2 | Office Chair | Home | 180 |
| 3 | Notebook | Stationery | 4.5 |
| 4 | Pen Set | Stationery | 12 |
| 5 | Headphones | Electronics | 95 |
| 6 | Webcam | Electronics | 60 |
| 7 | Mug | Home | 9 |
| 8 | Backpack | Travel | 70 |
Free, no account needed. PostgreSQL runs in your browser and your answer is checked again on changed data.
What this exercise teaches
String functions run per row, like arithmetic. UPPER, LOWER, LENGTH, TRIM and SUBSTR are the ones you use most; they are standard across SQLite, PostgreSQL and MySQL.
A hint if you get stuck
UPPER(text) changes the case and LENGTH(text) counts the characters. Both go in the SELECT list.
Background you need
Common mistakes on this exercise
- Name not converted to upper case.
- Lower case instead of upper case.
Each of these returns a result that looks plausible. The checker catches them because it runs your query on changed data as well.
Keep going on the practice page
Your first 8 exercises on Querydrill are free, with no account. The practice page has the full editor, timed mode and all the exercises in order. A free account shows 3 reference solutions a day; Pro unlocks every exercise, every solution, timed mode and the certificate.
Open this exerciseMore practice on the same topic
More exercises in Basics
- Pick two columns
- Filter rows
- Top three earners
- Count paid orders
- Each country once
- Small orders
- Two countries
- A date range
- Combine AND with OR
- Pattern match
- No manager
- Replace NULL with a default
- Sort on two columns
- Skip rows with OFFSET
- Calculated column
- Glue text together
- Label with CASE
- Search without caring about case (ILIKE)
- Full years of service (age)