CodeBlanks Logo Icon CodeBlanks

UPPER and LOWER

Convert text to upper or lower case.

UPPER and LOWER

UPPER converts text to uppercase, LOWER to lowercase. They are used for consistent search and comparison.

SELECT UPPER(name) AS upname FROM customers;

This query converts customer names to uppercase.

UPPER(name) AS upname is selected from customers.

UPPER and LOWER — details

To bypass case-sensitive search you write WHERE UPPER(name) = 'AYSE'. Some databases offer ILIKE for case-insensitive matching.

Practice UPPER and LOWER

Select name in uppercase from customers.

Starter code

query.sql
-- convert to uppercase
SELECT
FROM customers

Sample solution

query.sql
SELECT UPPER(name) AS upname
FROM customers

Expected output

upname
AYŞE
ALEX

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does UPPER do?

  • Joins text
  • Shortens text
  • Converts text to uppercase Correct answer
  • Deletes text

Explanation: UPPER converts text to uppercase.

2 Lowercase

Question
SELECT ____(name) FROM customers;
Answer
SELECT LOWER(name) FROM customers;

Explanation: LOWER converts text to lowercase; it removes case differences in comparisons.

3 UPPER and LOWER: match the terms

Term Meaning
UPPER uppercase
LOWER lowercase
LENGTH length
TRIM trim

All lessons in Beginner