DEV Community

Cover image for SQL ๐Ÿ“Š challenge_2โš”๏ธ
Mahmoud EL-kariouny
Mahmoud EL-kariouny

Posted on

SQL ๐Ÿ“Š challenge_2โš”๏ธ

Page With No Likes Facebook SQL Interview Question

  • 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.

โš ๏ธNote:

  • You have to visit the task URL to fully understand what the task needs if you want to add a solution or test your solution.
Task URL: Link

My Solution:

SELECT 
    p.page_id 
FROM
    pages p 
LEFT JOIN 
    page_likes l
ON
    p.page_id = l.page_id
GROUP BY 
    p.page_id
HAVING
    COUNT(l.page_id) = 0;
Enter fullscreen mode Exit fullscreen mode

Code Snapshot:

Image description

My Problem ๐Ÿ’ก Solving Repo: Link

Learn SQL ๐Ÿ“Š

SQL ๐Ÿ”ฅ Get Expertise in SQL with These Top Free Courses๐Ÿ’ฏ๐Ÿ†

๐ŸŽฅ

Connect with Me ๐Ÿ˜Š

๐Ÿ”— Links

linkedin

twitter

Top comments (0)