The UPPER function converts all letters in a text string to uppercase letters.
Click to reveal answer
beginner
How does the LOWER function affect a string in SQL?
The LOWER function changes all letters in a text string to lowercase letters.
Click to reveal answer
beginner
Explain what INITCAP does to a string in SQL.
INITCAP capitalizes the first letter of each word in a string and makes all other letters lowercase.
Click to reveal answer
beginner
Write a SQL query to convert the column 'name' to uppercase.
SELECT UPPER(name) FROM table_name;
Click to reveal answer
beginner
What will be the output of INITCAP('hello WORLD')?
The output will be 'Hello World' because INITCAP capitalizes the first letter of each word and makes the rest lowercase.
Click to reveal answer
Which function converts all letters in a string to lowercase in PostgreSQL?
AINITCAP
BUPPER
CLOWER
DTRIM
✗ Incorrect
LOWER converts all letters to lowercase.
What does INITCAP('good MORNING') return?
A'Good Morning'
B'good morning'
C'gOOD mORNING'
D'GOOD MORNING'
✗ Incorrect
INITCAP capitalizes the first letter of each word and makes the rest lowercase.
Which SQL function would you use to make a string all uppercase?
AUPPER
BINITCAP
CLOWER
DCONCAT
✗ Incorrect
UPPER converts all letters to uppercase.
If you apply LOWER to 'SQL DATABASE', what is the result?
A'SQL DATABASE'
B'sQL dATABASE'
C'Sql Database'
D'sql database'
✗ Incorrect
LOWER converts all letters to lowercase.
Which function capitalizes only the first letter of each word?
ALOWER
BINITCAP
CUPPER
DLTRIM
✗ Incorrect
INITCAP capitalizes the first letter of each word.
Describe the difference between UPPER, LOWER, and INITCAP functions in SQL.
Think about how each function changes the case of letters in a string.
You got /3 concepts.
Write example SQL queries using UPPER, LOWER, and INITCAP on a column named 'city'.
Use the function name followed by the column name in parentheses.
You got /3 concepts.
Practice
(1/5)
1. What does the UPPER function do to a text string in PostgreSQL?
easy
A. Reverses the string
B. Converts all letters to lowercase
C. Capitalizes only the first letter of the string
D. Converts all letters to uppercase
Solution
Step 1: Understand the UPPER function
The UPPER function changes every letter in the input text to its uppercase form.
Step 2: Compare with other options
LOWER converts to lowercase, INITCAP capitalizes first letters, reversing is unrelated.
Final Answer:
Converts all letters to uppercase -> Option D
Quick Check:
UPPER = all uppercase [OK]
Hint: UPPER means all letters become capital [OK]
Common Mistakes:
Confusing UPPER with LOWER
Thinking INITCAP only changes first letter of whole string
Assuming UPPER reverses text
2. Which of the following is the correct syntax to convert the column name to lowercase in PostgreSQL?
easy
A. SELECT LOWER name FROM table;
B. SELECT LOWER(name);
C. SELECT LOWER(name) FROM table;
D. SELECT name.LOWER() FROM table;
Solution
Step 1: Check function call syntax
In PostgreSQL, functions are called with parentheses around arguments, e.g., LOWER(name).
Step 2: Validate full query syntax
SELECT LOWER(name) FROM table; correctly uses SELECT LOWER(name) FROM table; which is valid SQL syntax.
Final Answer:
SELECT LOWER(name) FROM table; -> Option C
Quick Check:
Function call syntax = LOWER(name) [OK]
Hint: Use parentheses for functions: LOWER(column) [OK]
Common Mistakes:
Omitting parentheses after function name
Using dot notation like name.LOWER() which is invalid
Missing FROM clause in query
3. Given a table users with a column fullname containing 'john DOE', what is the output of the query SELECT INITCAP(fullname) FROM users;?
medium
A. 'John Doe'
B. 'John DOE'
C. 'John doe'
D. 'JOHN DOE'
Solution
Step 1: Understand INITCAP behavior
INITCAP capitalizes the first letter of each word and makes the rest lowercase.
Step 2: Apply to 'john DOE'
It converts 'john' to 'John' and 'DOE' to 'Doe'.
Final Answer:
'John Doe' -> Option A
Quick Check:
INITCAP('john DOE') = 'John Doe' [OK]
Hint: INITCAP capitalizes first letter of each word [OK]
Common Mistakes:
Assuming INITCAP only changes first word
Thinking it keeps uppercase letters as is
Confusing with UPPER or LOWER functions
4. Identify the error in this query: SELECT INITCAP fullname FROM employees;
medium
A. Column name should be uppercase
B. Missing parentheses around column name
C. Missing FROM clause
D. INITCAP is not a valid function
Solution
Step 1: Check function syntax
Functions require parentheses around their arguments, so INITCAP should be called as INITCAP(fullname).
Step 2: Verify other parts
FROM clause is present, INITCAP is valid, column case does not matter.
Final Answer:
Missing parentheses around column name -> Option B
Quick Check:
Function call needs parentheses [OK]
Hint: Always use parentheses with functions [OK]
Common Mistakes:
Omitting parentheses for function calls
Thinking column names must be uppercase
Confusing missing FROM clause error
5. You want to display a list of product names from the products table where each word in the product name starts with a capital letter, but the rest of the letters are lowercase. Which query achieves this?
hard
A. SELECT INITCAP(product_name) FROM products;
B. SELECT UPPER(product_name) FROM products;
C. SELECT LOWER(product_name) FROM products;
D. SELECT CONCAT(UPPER(SUBSTRING(product_name,1,1)), LOWER(SUBSTRING(product_name,2))) FROM products;
Solution
Step 1: Understand the requirement
Each word's first letter capitalized and rest lowercase matches INITCAP behavior.
Step 2: Evaluate options
The INITCAP option does exactly this. The UPPER option makes all uppercase, the LOWER option makes all lowercase, the CONCAT option only capitalizes first letter of whole string.
Final Answer:
SELECT INITCAP(product_name) FROM products; -> Option A
Quick Check:
INITCAP = capitalized words [OK]
Hint: Use INITCAP for capitalizing each word [OK]
Common Mistakes:
Using UPPER or LOWER instead of INITCAP
Trying to manually concatenate substrings for each word
Assuming INITCAP only affects first word
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.