Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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;