79252717

Date: 2024-12-04 21:06:10
Score: 0.5
Natty:
Report link

Few other approaches:

Fiddle

Approach 1

Check where the occupation is only scientist

SELECT department_id
FROM Department
GROUP BY department_id
HAVING COUNT(DISTINCT occupation) = 1
   AND MAX(occupation) = 'Scientist';

Approach 2

SELECT department_id
FROM Department d
WHERE NOT EXISTS (
    SELECT 1
    FROM Department d2
    WHERE d.department_id = d2.department_id
    AND d2.occupation != 'Scientist'
)
GROUP BY department_id;

Output

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: samhita