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

longest 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
Balazs Peak
46,160 Points

I 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
Balazs Peak
46,160 Points

there is an "AS" keyword missing, it should be the third word in this statement :) I hope this helps! Much love

Balazs Peak
Balazs Peak
46,160 Points

well, 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)

you're a legend ty... apparently I need some sleep :) good night!

Damn m8! you're really a legend :) I flew to fast over that task .. srry for my negligence :(

UPDATE: 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
Balazs Peak
46,160 Points

No problem! It was my pleasure helping you :D

thankyou , you're so kind... hope to see you around in future courses !