LinkedIn: Company Pages With No New Followers in May 2025

Easy
727.

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.

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

ColumnType
page_idint
company_namevarchar
industryvarchar

Primary key: page_id.

One row per company page.

Table: PageFollow

ColumnType
member_idint
page_idint
followed_ondate

Primary key (together): member_id, page_id.

A member following a page; page_id always names a page.

Example

The rows must come back in the order shown.

CompanyPage

page_idcompany_nameindustry
1Northwind LabsSoftware
2Saffron FintechBanking
3Lotus HealthHealthcare
4Indigo LearningEducation
5Cedar RoboticsManufacturing

PageFollow

member_idpage_idfollowed_on
1012025-05-01
1112025-04-12
1022025-04-30
1222025-06-01
1332025-05-31
1452025-03-15

Output

page_idcompany_name
2Saffron Fintech
4Indigo Learning
5Cedar Robotics
Read the hints, the editorial and the reference solution
-- Write your MySQL query below

Sign in to write, run and submit queries

A free account — no card, no trial clock. You come straight back here.

Run your query to see its result next to the expected one, example by example.

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

ColumnType
page_idint
company_namevarchar
industryvarchar

Primary key: page_id.

One row per company page.

Table: PageFollow

ColumnType
member_idint
page_idint
followed_ondate

Primary key: member_id, page_id.

A member following a page; page_id always names a page.

Examples

Example 1

CompanyPage

page_idcompany_nameindustry
1Northwind LabsSoftware
2Saffron FintechBanking
3Lotus HealthHealthcare
4Indigo LearningEducation
5Cedar RoboticsManufacturing

PageFollow

member_idpage_idfollowed_on
1012025-05-01
1112025-04-12
1022025-04-30
1222025-06-01
1332025-05-31
1452025-03-15

Output

page_idcompany_name
2Saffron Fintech
4Indigo Learning
5Cedar 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_id

Another 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_id

Another 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 →