Skip to the content

Fits on the spine

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

idtitle
1The Lighthouse
4Three Winters
5Loose Leaves
7Long Night
8Short 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 '% %'
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →