Querydrill

Level 1: Basics Exercise 18 of 161 Easy Filter and sort

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)

idnamecategoryprice
1Desk LampHome35
2Office ChairHome180
3NotebookStationery4.5
4Pen SetStationery12
5HeadphonesElectronics95
6WebcamElectronics60
7MugHome9
8BackpackTravel70

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 exercise

More practice on the same topic

More exercises in Basics