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

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!

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!

Thuy Van Ngo
Thuy Van Ngo
3,289 Points

Thanks a lot! Yes, it passes. It's very frustrating doing this kind of challenge where no answer seems to be correct.