SQL
Lab
LinkedIn Easy Group By Ranking

Most Active
Hiring
Company

Find the company that posted the highest number of job listings.

Table Schema

Inspect
Table

interactive
ColumnTypeDescription
job_idintegerUnique job posting identifier.
company_idintegerIdentifier for the company posting the job.
company_namestringName of the company posting the job.
titlestringJob listing title.
locationstringJob location.
posted_datedateDate the job was posted.
salaryintegerListed salary.

Sample Data

Input
Output

Sample Input: job_listings
job_idcompany_idcompany_nametitlelocationposted_datesalary
1011ABC CorpData AnalystNY2024-01-0170000
1021ABC CorpData ScientistSF2024-01-05120000
1032XYZ IncData AnalystTX2024-01-0380000
1041ABC CorpML EngineerNY2024-01-10130000
1053TechSoftAnalystCA2024-01-0260000
1062XYZ IncEngineerTX2024-01-0790000
Expected Output
company_idjob_count
13

SQL Editor

Run
Query

postgresql
Waiting for query

company_idjob_count
13

Hints

Unlock
Clues

Hint 01: Group rows by company_id so every company has one group.
Hint 02: Use COUNT(*) AS job_count to count how many listings each company posted.
Hint 03: Order by job_count DESC and LIMIT 1 to return the top company.

Solution

Locked
Answer

Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.

SELECT
  company_id,
  COUNT(*) AS job_count
FROM job_listings
GROUP BY company_id
ORDER BY job_count DESC
LIMIT 1;

Explanation

Step By
Step

01

Group rows by company_id so each company becomes one output group.

02

Use COUNT(*) to calculate how many job listings each company posted.

03

Sort by job_count descending and use LIMIT 1 to keep the most active hiring company.

Related Questions

Keep
Solving