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
29,951 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

53,479 Points

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