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 trialWouter Vermeersch
6,913 Pointslongest length function,
My code works and returns the correct result.. unfortunately I can't pass because of the validation mechanism for somehow.
SELECT title longest_length FROM books ORDER BY LENGTH(title) DESC LIMIT 1 ;
6 Answers
Balazs Peak
46,160 PointsI looked up the challenge for you. The description says "Show the title and then the length.". So you have to report the length also, not just using it in ordering. :) Not to mention, that you should have aliased the length as "longest_length", not the title. The title should be reported as title. Solution:
SELECT title, LENGTH(title) AS longest_length FROM books ORDER BY LENGTH(title) DESC LIMIT 1;
Balazs Peak
46,160 Pointsthere is an "AS" keyword missing, it should be the third word in this statement :) I hope this helps! Much love
Balazs Peak
46,160 Pointswell, it comes out that in terms of SQL it is not necessary. But maybe the challenge on treehouse is expecting you to do so? (I didn't find other mistakes either)
Wouter Vermeersch
6,913 Pointsyou're a legend ty... apparently I need some sleep :) good night!
Wouter Vermeersch
6,913 PointsDamn m8! you're really a legend :) I flew to fast over that task .. srry for my negligence :(
Wouter Vermeersch
6,913 PointsUPDATE: for some strange reason it doesn't let me pass:
SELECT title AS longest_length FROM books ORDER BY LENGTH(title) DESC LIMIT 1 ;
longest_length Harry Potter and the Order of the Phoenix
Balazs Peak
46,160 PointsNo problem! It was my pleasure helping you :D
Wouter Vermeersch
6,913 Pointsthankyou , you're so kind... hope to see you around in future courses !