Databases Reporting with SQL Working with Text Getting the Length of a String

4 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 50,933 Points

You will want to order by longest_length instead of the length function

Shreemangal Sethi
Shreemangal Sethi
Full Stack JavaScript Techdegree Student 7,506 Points

SELECT title, LENGTH(title) AS longest_length FROM books ORDER BY length DESC LIMIT 1;

Kiran Kumar
Kiran Kumar
4,754 Points

There's no column called length in the table, books; Like Kris explained above use the alias, longest_length which contains length of title.