-1

I am currently struggleling determining which jobs exist in all departments. The given table is this one.

enter image description here

I have the feeling that this is actually very simple, but I can't figure out how to do it.

The problem is basically, that only the jobs "CLERK" and "MANAGER" should be returned, because they exist in every deparment (department 10, 20 and 30 e.g). If you look closely you'll see that, for example, "PRESIDENT" only exists in department 10.

If anyone knows a simple solution for that I would be very thankfull

Thanks in advance for every response and hopefully there is somebody who is smarter than me at the moment

Important: Im on PostgreSQL

Timmske
  • 115
  • 1
  • 6

1 Answers1

2

You can use aggregation and having:

select job
from t
group by job
having count(distinct deptno) = (select count(distinct deptno) from t);
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786