Suppose I have a SQL table "Company" with three columns: "department_id", "employee", "job". Something like that:
DEPARTAMENT_ID | EMPLOYEE | JOB -------------------------------------- 1 | Mark | President 1 | Robert | Marketing Manager 1 | Rose | Administration Assitant 2 | Anna | Programmer 2 | Michael | Programmer 2 | Celia | Sales Manager 3 | Jhon | Sales Manager 3 | Donna | Programmer 3 | David | Marketing Manager
I would like to write a query that returns the id of departments where at least 50% of their jobs are the same.
The result that I need in my example will be simple:
DEPARTAMENT_ID | -------------------------------------- 2 |
How to write this SQL query? I think I tried all kinds of things, but I do not understand: (.
Mayra source share