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

Kamran Ismayilov
Kamran Ismayilov
5,753 Points

What am I doing wrong?

In an ecommerce database there's a customers table with id, username, first_name, last_name, password, email and phone columns. 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.

My solution is:

SELECT SUBSTR(first_name, 1, 1) || " " || "&" " " || last_name AS initial FROM customers;

Why this? because Bummer keeps typing Expecting results L & Chalkey NOT L & Chalkley though I got the same result.

4 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Kamran,

Without seeing the actual challenge I can only guess what may be the problem.

It's always best to click the "Get Help" button from the actual challenge, video, or quiz, as this will link your code and the actual challenge, video, or quiz you are at the course for us to reference.

For your code, you could try eliminating the first and last set of quotes you are using to add a space, and include the space before and after the ampersand itself.

SELECT SUBSTR(first_name, 1, 1) || " & " || last_name AS initial FROM customers;

Both will result in the same output, but sometimes challenges are quite picky. If this doesn't solve you issue, you will need to link to the actual challenge, either by re-submitting your question using the "Get Help" button in the challenge, or copy/paste the URL link to the actual challenge here in a comment.

:dizzy:

Micah Dunson
Micah Dunson
34,368 Points

According to the challenge, it never says anything about having to use concatenation so you can solve with: SELECT SUBSTR(first_name, 1, 1) AS initial, last_name FROM customers;

Robin Burgess
Robin Burgess
4,110 Points

Why are you using an ampersand (&)? Also, I believe the challenge wants you to alias the first initial as "initial," not the whole thing. That way, you end up with the value "L" under the column "initial" and "Chalkley" under the column "last_name".