I'm asked to return the title, and length as an alias with the highest one being returned.
I'm not seeing what the issue is?
Steven Parker167,746 Points
Do you mean you don't understand the instructions? Let's break them down:
"Find the book with the longest title. Show the title and then the length. Alias the result of the length calculation to be
longest_length. Only retrieve the longest book."
So you'll need to:
- select the title, and the length of the title
- give the length an alias as the name
- order by the length of the title
- order with descending values (longest titles first)
- limit the results to just the first one
I'll bet you can get it now — give it a try.
Yes I see what I did...
select title, LENGTH(title) as longest_length FROM books ORDER BY length desc limit 1; --This failed
select title, LENGTH(title) as longest_length FROM books ORDER BY longest_length desc limit 1; --This PASSED
I didn't order by by Alias longest_length appropriately.