Fits on the spine
- O(1) · Trivial
- Free
- SQL
- strings
- filtering
Problem
The new spine labels are in, and they come in three sizes. Today the medium ones go on. Those are for titles of exactly two words: a one-word title gets the small label, and a title of three words or more gets the long one.
Show the id and the title of the books that get the medium label, in that order. In books, the words of a title are separated by a single space, and no title starts or ends with one.
What it has to return
These rows, in any order
| id | title |
|---|---|
| 1 | The Lighthouse |
| 4 | Three Winters |
| 5 | Loose Leaves |
| 7 | Long Night |
| 8 | Short Stories |
This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.
You start with this
SQL
SELECT id, title
FROM books
WHERE title LIKE '% %'It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.