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 trialJoseph Romero
6,129 PointsIn 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
Ondřej Havazík
7,801 PointsYou should do something like this:
SELECT SUBSTR(first_name,1,1) AS "initial", last_name FROM customers;
Steven Parker
231,261 Points
you aliased your first column as intital
, but it needs to be initial
.
Timothy Sawyer
31,052 PointsI 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
3,233 PointsFound the right one! SELECT SUBSTR( first_name,1,1) AS initial, last_name FROM customers;
Don't concatenate in this specific challenge.
Dan Epstein
3,233 PointsI 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?
Simone Beaver
Full Stack JavaScript Techdegree Graduate 15,720 PointsSELECT <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.
Charlie Harcourt
8,046 PointsCharlie Harcourt
8,046 PointsThanks! :)