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

Hi, why is this wrong? select title, length(title) AS longest_length from books order by length limit 1;

Hi I'm struggling to see where I'm wrong for this question. I would be grateful if anyone could provide an explanation or some feedback. Thanks in advance!

1 Answer

Hey @Cherub you are very close here. :-) so we are wanting to order the books by length, which you aliased as longest_length. What we want to do is ORDER BY longest_length. By default ORDER BY orders the items in ascending order. If we do not specify whether we want it in ASC or DESC order, what you currently have will select the smallest length. So if you add DESC to the end of ORDER BY longest_length and limit that to one that should pass. Great job!