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 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,164 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
LIMIT 1;

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