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

donald kaiser
donald kaiser
9,736 Points

I'm not understanding how to only show the first initial of someone's name using the SUBSTR function.

https://teamtreehouse.com/library/reporting-with-sql/working-with-text/creating-excerpts

Here is my code, I didn't include SUBSTR in my code because I need some help on how to go about doing it.

SELECT first_name AS "initial", last_name FROM customers;

1 Answer

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

SUBSTR function takes 3 parameters:

  • substr(value, start, length) - where the start is 1 index based.

So :

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