Count users by the number of distinct job_title values they posted. Return one row with same_job (users with exactly one distinct title) and different_jobs (users with more than one distinct title).
Input Table(s)
job_postings
| column | type | meaning |
|---|
| id | INTEGER | Posting identifier (primary key) |
| job_title | VARCHAR(255) | Title of the job posted, never NULL |
| user_id | INTEGER | User who posted the job, never NULL |
| date_posted | TIMESTAMP | When the job was posted |
Output Contract
Return exactly one row with these columns, in this order:
| column | meaning |
|---|
| same_job | Number of users with exactly one distinct job_title |
| different_jobs | Number of users with more than one distinct job_title |
Both values are integer counts. The result is always a single row, so no ordering applies.
Example
job_postings
| id | job_title | user_id | date_posted |
|---|
| 1 | Software Engineer | 101 | 2024-01-10 09:00:00 |
| 2 | Software Engineer | 101 | 2024-01-15 10:00:00 |
| 3 | Data Analyst | 102 | 2024-01-12 11:00:00 |
| 4 | Product Manager | 102 | 2024-01-13 12:00:00 |
| 5 | Designer | 103 | 2024-01-14 13:00:00 |
Expected result:
User 101 posted only "Software Engineer" (1 distinct title) and user 103 posted only "Designer" (1 distinct title), so same_job is 2. User 102 posted 2 distinct titles, so different_jobs is 1.
Constraints and Clarifications
-
The table has between 1 and 100,000 rows.
-
id
is unique.
user_id
and
job_title
are never NULL, so every user has at least one distinct title and falls into exactly one of the two counts.
-
A user may post the same job title multiple times. Repeats of one title count as a single distinct title.
-
Titles are compared exactly as stored.
-
date_posted
does not affect the answer.