Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Madhuri Maddala
PLUS
Madhuri Maddala
Courses Plus Student 793 Points

Create a report from the customers table that shows their first initial of their first name and alias it as initial. Sel

Create a report from the customers table that shows their first initial of their first name and alias it as initial. Select their last name too.

Madhuri Maddala
Madhuri Maddala
Courses Plus Student 793 Points

select SUBSTR(first_name,1,1) || " " || last_name as intial from customers. I have written this code and it returning correct format and still getting incorrect query message. Could some one help me in this?

3 Answers

Benjamin Larson
Benjamin Larson
34,055 Points

Madhuri -

Your SUBSTR function is correct, but you don't need the concatenation operators (||) or the string (" ") in this example. Also, there are two column you are selecting: the first letter of the first_name, and the last_name. SQL syntax requires you to put a comma between each column you are selecting. The way you have it written now, SQL doesn't understand because it's missing the comma and your alias to "intial" (which needs to be "initial"), is being associated with last_name, not the substring of the first_name.

Hopefully this makes sense and you can take another stab at it. If not, feel free to ask more questions.

SELECT SUBSTR(first_name, 1, 1), last_name AS "initial" FROM customers;. Can someone please help with this one. I can't seem to get it.

It asks to make the first_name an alias, then add the last_name 
SELECT SUBSTR(first_name, 1, 1) AS initial , last_name AS last_name FROM customers;