Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,089 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,089 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,089 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,089 Points

No problem! It was my pleasure helping you :D

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