Ctr

Latest Tweets

We'll write a query which is a basic necessity for Tweeter: the news feed! Given a user ID, we need to generate their news feed, which is a list of recent tweets from users they follow. Our growth analysts say that people don't like to see more than 2 tweets from the same user in their feed at any given time. So, we need to select all the users someone follows, and their (at most) 2 most recent tweets. For now, let's just write a query to do this for user ID 15.


tweeters
column_name type
id
INTEGER
username
VARCHAR
email
VARCHAR
registered_at
TIMESTAMPTZ

tweets
column_name type reference
id
INTEGER
NULL
body
TEXT
NULL
user_id
INTEGER
tweeters.id
created_at
TIMESTAMPTZ
NULL

follows
column_name type reference
follower_id
INTEGER
tweeters.id
followed_id
INTEGER
tweeters.id
created_at
TIMESTAMPTZ
NULL

Select all users that user 15 follows (all columns), as well as the (up to) 2 most recent tweets from each user. Order the results by the newest first, oldest last.

© 2022 Andrew Carlson. All rights reserved.

id
INTEGER
username
VARCHAR
email
VARCHAR
registered_at
TIMESTAMPTZ
recent_tweet
TEXT
tweet_created_at
TIMESTAMPTZ
1
1
deonte_murray45
deonte_murray57@hotmail.com
2021-08-02 08:54:42.061+00
generating the protocol won't do anything, we need to back up the virtual USB hard drive!
2021-12-20 11:41:28.716+00
2
1
deonte_murray45
deonte_murray57@hotmail.com
2021-08-02 08:54:42.061+00
You can't input the circuit without hacking the back-end CSS matrix!
2021-11-13 01:05:58.795+00
3
11
judy.blick60
judy14@yahoo.com
2014-02-11 02:53:02.395+00
generating the system won't do anything, we need to quantify the optical SQL firewall!
2021-06-16 12:42:05.054+00
4
5
annabelle74
annabelle_erdman83@hotmail.com
2016-07-27 14:03:26.745+00
If we input the monitor, we can get to the IB transmitter through the primary HDD transmitter!
2018-07-26 05:28:38.075+00
5
11
judy.blick60
judy14@yahoo.com
2014-02-11 02:53:02.395+00
I'll generate the optical IB bandwidth, that should application the AGP program!
2016-09-09 10:18:32.523+00
5 rows

You haven't solved this challenge yet!
Are you sure you want to reveal the answer?