NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

Table: job_listings

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| job_id      | integer |
| company_id  | integer |
| title       | varchar |
| description | varchar |
+-------------+---------+

job_id is the primary key. Each row represents a job posting from a company.

Write a solution to find the number of companies that have posted duplicate job listings. A duplicate listing means two or more listings from the same company with the same title and description. Return the count as duplicate_companies.

The result format is shown below.

Example

Input:

job_listings table:
+--------+------------+------------------+-----------------------+
| job_id | company_id | title            | description           |
+--------+------------+------------------+-----------------------+
| 248    | 827        | Business Analyst | Analyze business data |
| 149    | 845        | Business Analyst | Review business data  |
| 945    | 345        | Data Analyst     | Analyze product data  |
| 164    | 345        | Data Analyst     | Analyze product data  |
| 172    | 244        | Data Engineer    | Build data systems    |
+--------+------------+------------------+-----------------------+

Output:

+---------------------+
| duplicate_companies |
+---------------------+
| 1                   |
+---------------------+

Explanation:
Companies 827 and 845 each posted one listing titled "Business Analyst" but with different company IDs, so they are not the same company. Only company 345 posted the same title and description twice (job IDs 945 and 164), so the answer is 1.


Accepted
18/71
Acceptance Rate25.4%
Test Cases
Input
-
Output
-
Expected
-