logo

Back to questions

Page With No Likes [Facebook SQL Interview Question]

Easy

Assume you're given two tables containing data about Facebook Pages and their respective likes (as in "Like a Facebook Page").

Write a query to return the IDs of the Facebook pages that have zero likes. The output should be sorted in ascending order based on the page IDs.

Table:

Column NameType
page_idinteger
page_namevarchar

Example Input:

page_idpage_name
20001SQL Solutions
20045Brain Exercises
20701Tips for Data Analysts

Table:

Column NameType
user_idinteger
page_idinteger
liked_datedatetime

Example Input:

user_idpage_idliked_date
1112000104/08/2022 00:00:00
1212004503/12/2022 00:00:00
1562000107/25/2022 00:00:00

Example Output:

page_id
20701

The dataset you are querying against may have different input & output - this is just an example!

p.s. If you have literally no idea how to solve this, maybe give our free SQL tutorial a try first?

PostgreSQL 14