You are on page 1of 2

SQl exercise 

You are going to be working with a small sample of social-media like data.
There are two tables, users, which contains basic information about people profiles, and follows,
which lists which users follow another given user.
The users table will thus look like something like the below, with the user_id, first_name,last_name
and country columns.

Users table
user_i
d first_name last_name house
1 Harry Wesley USA
2 Ron Granger Canada
3 Hany Michetch Brazil

The follows table will then report information of which two user ids form a relationship in which the
former follows the latter. The columns will thus be user_id, follows (the user_id of the user being
followed), and the date in which the “following” relationship was created.
user_i
d follows date
1 2 1993-09-01
2 1 1989-01-01
3 1 1993-07-01
2 3 1994-10-10
3 2 1995-03-01

Questions:
1. How many users are there in each country?
2. List all following links that were created before September 1st, 1993

3. List all the following links established before September 1st 1993, but this time use the users
first names
(Result should look like this:)

4. Give a count of how many people followed each user as of 1999–12–31. Give the result in
term of “user full name, number of followers”
(result should look like this:)
5. List the number of users each user follows

You might also like