LinkedIn: Company Pages With No New Followers in May 2025
The Pages team reaches out to company admins whose page stopped growing, starting with the pages that gained nobody in May.
- Difficulty: Easy
- Topics: Joins, Subqueries
- Dialect: MySQL
- Problem: #727
Problem statement
The Pages team reaches out to company admins whose page stopped growing, starting with the pages that gained nobody in May.
Return page_id and company_name of every company page that has no follow dated in May 2025 (2025-05-01 to 2025-05-31 inclusive). A page with follows only in other months, or with no follows at all, is in the answer. Order the rows by page_id.
A practice scenario set at LinkedIn: the tables and data are invented, and this is not a question from, or endorsed by, LinkedIn.
Tables
Table: CompanyPage
| Column | Type |
|---|---|
| page_id | int |
| company_name | varchar |
| industry | varchar |
Primary key: page_id.
One row per company page.
Table: PageFollow
| Column | Type |
|---|---|
| member_id | int |
| page_id | int |
| followed_on | date |
Primary key: member_id, page_id.
A member following a page; page_id always names a page.
Examples
Example 1
CompanyPage
| page_id | company_name | industry |
|---|---|---|
| 1 | Northwind Labs | Software |
| 2 | Saffron Fintech | Banking |
| 3 | Lotus Health | Healthcare |
| 4 | Indigo Learning | Education |
| 5 | Cedar Robotics | Manufacturing |
PageFollow
| member_id | page_id | followed_on |
|---|---|---|
| 10 | 1 | 2025-05-01 |
| 11 | 1 | 2025-04-12 |
| 10 | 2 | 2025-04-30 |
| 12 | 2 | 2025-06-01 |
| 13 | 3 | 2025-05-31 |
| 14 | 5 | 2025-03-15 |
Output
| page_id | company_name |
|---|---|
| 2 | Saffron Fintech |
| 4 | Indigo Learning |
| 5 | Cedar Robotics |
How to solve LinkedIn: Company Pages With No New Followers in May 2025
This is an anti join: keep each page for which no May follow exists. NOT EXISTS says exactly that — the subquery looks for a follow of this page dated in May, and the page survives only if none is found. Pages with follows only in April or June, and pages nobody follows, both pass, which is what the team wants.
The LEFT JOIN version needs care: the May condition must sit in the ON clause, so that a page whose follows are all outside May still produces one row with NULLs, which WHERE f.page_id IS NULL then keeps. Putting the date test in WHERE would turn it back into an inner join and lose those pages. The NOT IN version is safe here because PageFollow.page_id is never NULL — with a nullable column, a single NULL in the list would make NOT IN return nothing.
Both boundaries count: a follow on 2025-05-01 or 2025-05-31 is a May follow. With an index on (page_id, followed_on) each probe is a short range lookup.
Reference solution (MySQL)
SELECT p.page_id, p.company_name
FROM CompanyPage p
WHERE NOT EXISTS (
SELECT 1 FROM PageFollow f
WHERE f.page_id = p.page_id
AND f.followed_on BETWEEN '2025-05-01' AND '2025-05-31'
)
ORDER BY p.page_idAnother way
SELECT p.page_id, p.company_name FROM CompanyPage p LEFT JOIN PageFollow f ON f.page_id = p.page_id AND f.followed_on >= '2025-05-01' AND f.followed_on < '2025-06-01' WHERE f.page_id IS NULL ORDER BY p.page_idAnother way
SELECT page_id, company_name FROM CompanyPage WHERE page_id NOT IN (SELECT page_id FROM PageFollow WHERE YEAR(followed_on) = 2025 AND MONTH(followed_on) = 5) ORDER BY page_id← LinkedIn: Skills Endorsed by Three or More Different People · LinkedIn: InMail Response Rate per Recruiter →