Skip to content
>_sqlbuddy

Invalid Tweets

Find tweets whose content is longer than 15 characters.

Start practice

Problem statement

Prompt

Given the tweets table below, write a query that returns the tweet_id of every tweet whose content is longer than 15 characters.

  • A tweet is _invalid_ when LENGTH(content) > 15.
  • Output a single column: tweet_id.

Example

tweet_idcontent
1Let us code
2More than fifteen chars!

Expected result:

tweet_id
2

Constraints

  • tweets.tweet_id is the primary key.

Tips

  • In SQLite, LENGTH(content) counts characters — exactly what we want here.

Schema

CREATE TABLE tweets (
    tweet_id INTEGER PRIMARY KEY,
    content  TEXT NOT NULL
);

Sample data

INSERT INTO tweets (tweet_id, content) VALUES
  (1, 'Let us code'),
  (2, 'More than fifteen chars!'),
  (3, 'short'),
  (4, 'This one is definitely way too long to be a valid tweet');

Additional hidden fixtures are applied during validation to test edge cases.

Solution

One correct approach — try solving it yourself in the practice editor first, then compare. There is usually more than one valid solution.

-- Reference: tweets longer than 15 characters.
SELECT tweet_id
FROM tweets
WHERE LENGTH(content) > 15
ORDER BY tweet_id;

Key concepts

  • LENGTH
  • String comparison

Related questions

Learn more