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 Reporting with SQL Working with Text Getting the Length of a String

what should be the code for challenge 1 for finding the length of TEXT, I have tried different methods

first of all I have put SELECT title, LENGTH (title) AS "longest_title" FROM books ORDE BY DECS; However it is keep giving me an error. Can you please help me?

Tommy Gebru
Tommy Gebru
30,150 Points

Hey Sevdiye you have some typos in the code you shared but KRIS has some great hints to get you going :thumbsup:

If you havent already worked through this challenge, your solution should look like this

SELECT title, LENGTH(title) AS longest_length
FROM books
ORDER BY longest_length DESC

Thank you Tommy and Kris.

1 Answer

Some hints:

  • the alias for longest title is "longest_length"
  • You can order by this alias: ORDER BY longest_length DESC
  • You will need to limit your results to one record