Skip to content
Advertisement

postgreSQL LEFT and UPPER interaction

Question: Write a query that returns the name, address, state, and zipcode from all purchases. For the names, return only the first 5 characters, and display them in all uppercase letters, sorted in alphabetical order.

Code so far:

SELECT LEFT (name, 5) AS UPPER, address, state, zipcode
FROM purchases
ORDER BY name;

I’m at a loss of where and how to use UPPER to capitalize all the characters in the first column that is being returned. So far this is 9/10 checks passed for my code.

Advertisement

Answer

Add upper function in your query

SELECT UPPER(LEFT('JOhNdOEISMYNAME', 5)) AS UPPER
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement