Bird
Raised Fist0
SQLquery~10 mins

UPPER and LOWER functions in SQL - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to convert the 'name' column to uppercase.

SQL
SELECT [1](name) FROM employees;
Drag options to blanks, or click blank then click option'
ALENGTH
BUPPER
CLOWER
DCOUNT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOWER instead of UPPER will convert text to lowercase.
Using LENGTH or COUNT will not change text case.
2fill in blank
medium

Complete the code to convert the 'city' column to lowercase.

SQL
SELECT [1](city) FROM locations;
Drag options to blanks, or click blank then click option'
ALOWER
BSUBSTR
CTRIM
DUPPER
Attempts:
3 left
💡 Hint
Common Mistakes
Using UPPER will convert text to uppercase, not lowercase.
TRIM and SUBSTR do not change text case.
3fill in blank
hard

Fix the error in the code to convert 'product_name' to uppercase.

SQL
SELECT [1](product_name) FROM products;
Drag options to blanks, or click blank then click option'
ACOUNT
BLOWER
CLENGTH
DUPPER
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOWER instead of UPPER changes text to lowercase.
Forgetting the closing parenthesis causes syntax errors.
4fill in blank
hard

Fill both blanks to convert 'last_name' to lowercase and alias it as 'lname'.

SQL
SELECT [1](last_name) AS [2] FROM staff;
Drag options to blanks, or click blank then click option'
ALOWER
BUPPER
Clname
Dlastname
Attempts:
3 left
💡 Hint
Common Mistakes
Using UPPER instead of LOWER changes text to uppercase.
Using 'lastname' as alias instead of 'lname' does not match the instruction.
5fill in blank
hard

Fill all three blanks to select uppercase 'first_name', lowercase 'email', and alias 'phone_number' as 'contact'.

SQL
SELECT [1](first_name), [2](email), phone_number AS [3] FROM contacts;
Drag options to blanks, or click blank then click option'
ALOWER
BUPPER
Ccontact
Dphone
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up UPPER and LOWER functions.
Using wrong alias names that do not match the instruction.

Practice

(1/5)
1. What does the SQL function UPPER('Hello World') return?
easy
A. 'Hello World'
B. 'HELLO WORLD'
C. 'hello world'
D. 'HeLLo WoRLD'

Solution

  1. Step 1: Understand the UPPER function

    The UPPER function converts all letters in the input string to uppercase letters.
  2. Step 2: Apply UPPER to 'Hello World'

    Converting each letter to uppercase results in 'HELLO WORLD'.
  3. Final Answer:

    'HELLO WORLD' -> Option B
  4. Quick Check:

    UPPER('Hello World') = 'HELLO WORLD' [OK]
Hint: UPPER makes all letters capital [OK]
Common Mistakes:
  • Confusing UPPER with LOWER
  • Thinking it changes only first letter
  • Assuming it reverses the string
2. Which of the following is the correct syntax to convert a column named name to lowercase in SQL?
easy
A. SELECT LOWER(name) FROM table;
B. SELECT LOWER name FROM table;
C. SELECT name.LOWER() FROM table;
D. SELECT LOWER[name] FROM table;

Solution

  1. Step 1: Recall correct function syntax

    The LOWER function is called with parentheses around the column name: LOWER(column_name).
  2. Step 2: Check each option

    SELECT LOWER(name) FROM table; uses correct syntax: LOWER(name). Others have syntax errors or invalid notation.
  3. Final Answer:

    SELECT LOWER(name) FROM table; -> Option A
  4. Quick Check:

    Use LOWER(column) with parentheses [OK]
Hint: Use LOWER(column_name) with parentheses [OK]
Common Mistakes:
  • Omitting parentheses
  • Using dot notation like name.LOWER()
  • Using square brackets inside function
3. Given a table users with a column username containing values: 'Alice', 'BOB', 'charlie', what will the query SELECT LOWER(username) FROM users; return?
medium
A. ['ALICE', 'BOB', 'CHARLIE']
B. ['Alice', 'BOB', 'charlie']
C. ['alice', 'bob', 'charlie']
D. ['aLiCe', 'bOb', 'cHaRlIe']

Solution

  1. Step 1: Understand LOWER function effect on each username

    LOWER converts all letters to lowercase regardless of original case.
  2. Step 2: Apply LOWER to each username

    'Alice' -> 'alice', 'BOB' -> 'bob', 'charlie' -> 'charlie'.
  3. Final Answer:

    ['alice', 'bob', 'charlie'] -> Option C
  4. Quick Check:

    LOWER converts all letters to lowercase [OK]
Hint: LOWER makes all letters small [OK]
Common Mistakes:
  • Assuming only first letter changes
  • Confusing LOWER with UPPER
  • Expecting mixed case output
4. Identify the error in this SQL query: SELECT LOWER username FROM users;
medium
A. No error, query is correct
B. LOWER function does not exist
C. Table name is incorrect
D. Missing parentheses around column name

Solution

  1. Step 1: Check function syntax

    SQL functions require parentheses around arguments, so LOWER(username) is correct.
  2. Step 2: Identify missing parentheses

    The query uses LOWER username without parentheses, causing syntax error.
  3. Final Answer:

    Missing parentheses around column name -> Option D
  4. Quick Check:

    Functions need parentheses [OK]
Hint: Always use parentheses with functions [OK]
Common Mistakes:
  • Omitting parentheses for functions
  • Assuming functions work like keywords
  • Ignoring syntax errors
5. You want to find all rows in a table products where the category column equals 'Books', ignoring case differences. Which SQL WHERE clause correctly does this?
hard
A. WHERE LOWER(category) = 'books' AND UPPER(category) = 'BOOKS'
B. WHERE category = 'Books'
C. WHERE LOWER(category) = 'Books'
D. WHERE UPPER(category) = 'BOOKS'

Solution

  1. Step 1: Understand case-insensitive comparison

    To ignore case, convert both sides to the same case before comparing.
  2. Step 2: Apply LOWER and UPPER to category and compare both

    Using WHERE LOWER(category) = 'books' AND UPPER(category) = 'BOOKS' ensures the category matches 'Books' ignoring case by checking both lowercase and uppercase.
  3. Final Answer:

    WHERE LOWER(category) = 'books' AND UPPER(category) = 'BOOKS' -> Option A
  4. Quick Check:

    Use both LOWER and UPPER on the column to ensure case-insensitive match [OK]
Hint: Convert both sides to same case for comparison [OK]
Common Mistakes:
  • Comparing without case conversion
  • Mixing cases in comparison string
  • Using only one case function
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard