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

Joseph Romero
Joseph Romero
6,129 Points

In an ecommerce database (SUBSTR function help)

The question:

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.

This is my current answer. I feel it meets the question's needs. However it still says its wrong.

```SQL SELECT SUBSTR(first_name, 1, 1) AS intital, last_name FROM customers ```

output

intital last_name

L Chalkley

D McFarland

P Premaratne

A Chalkley

R Hinkley

L Love

N Pettit

C Tepper

J Hoskins

M Pole

5 Answers

You should do something like this:

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

Thanks! :)

Steven Parker
Steven Parker
231,261 Points

:point_right: you aliased your first column as intital, but it needs to be initial.

Timothy Sawyer
Timothy Sawyer
31,052 Points

I did the same thing, I misspelled "initial". The error message got me. It stated something like "looking for L & Chalkley not L & Chalkley" .

Dan Epstein
Dan Epstein
3,233 Points

Found the right one! SELECT SUBSTR( first_name,1,1) AS initial, last_name FROM customers;

Don't concatenate in this specific challenge.

Dan Epstein
Dan Epstein
3,233 Points

I tried this: SELECT SUBSTR( first_name,1,1)||" "||last_name AS initial FROM customers;

yet I get this strange error reply: Bummer: Expecting results like 'L Chalkley' not 'L Chalkley'.

Any insights?

SELECT <item> AS "item", <item> AS "item", <item> AS "item" FROM table; this works for me and of course you wont use item but this is to get you a nudge in the right direction.