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 trialqianyi wang
601 PointsI do not know the correct answer
select title , length(title) as longest_length from books order by longest_length limit 1;
why this answer is not correct , can anyone give me the correct answer?
1 Answer
jcorum
71,830 PointsYou didn't give a link to the challenge, and you didn't say what the challenge wants, so I'm guessing. But try this:
SELECT title , length(title) as longest_length FROM books ORDER BY length(title) DESC limit 1;
Some DBMSs won't let you use an alias in ORDER BY. You need the DESC to put the longest title first, so that when you limit the query to one row you do get the longest.