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 Reporting with SQL Working with Text Getting the Length of a String

Jessie Starborne
Jessie Starborne
6,155 Points

This question doesn't clearly state how it wants longest_length formatted.

Tried a few different methods of stringing together the title and the length, but it doesn't like any of them. :/

1 Answer

Hi Jesse!

This passes:

SELECT title, LENGTH(title) AS longest_length
FROM books
ORDER BY LENGTH(title) DESC
LIMIT 1;

And/But there are other ways to get the same or even better results.

More info:

https://tableplus.com/blog/2019/09/select-rows-with-longest-string-value-sql.html

I hope that helps.

Stay safe and happy coding!

Jessie Starborne
Jessie Starborne
6,155 Points

Yeah, I realized after a while that the question wasn't asking to concatenate the title with the length into longest_length, but to simply select both. x.X

Thank you for your help!