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

tomd
tomd
14,587 Points

I've tried maybe 10 variations, and I still can't pass.

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

Im missing something somewhere..

1 Answer

tomd
tomd
14,587 Points

I found the answer, I had to go back a few videos, find the books database and try out my code there. Its pretty hard to debug in these challenges when you have no feedback and no database to look at.

Brendan Whiting
Brendan Whiting
Front End Web Development Treehouse Moderator 82,609 Points

It is a bit tricky to debug in the challenge. But you could run a very similar query in the SQL Playground that you can launch from the video to make sure you have the right syntax. For example SELECT name, LENGTH(name) as longest_length FROM products ORDER BY longest_length DESC LIMIT 1;