First of all, I really don’t know how to formulate my question.
I have different companies in a database.
I would like to know which companies doesn’t have an "analyst" profile.
Here is my query:
select
t.name as "name"
t.pre as "first name"
t.id as "# account"
t.profile as "Profile"
b.cod_miss as "Mission"
b.df_missn as "End date"
from sr.v t
inner join od.e_lds on t.niu_ld = b.niu_ld
where b.cod_miss = 'APPROV'
and t.profile = 'Analyst'
This query gives me all the analyst for every companies in my database.
But I would like to have all the companies that does NOT have any analyst.
how do I do it? I tried using ‘and t.profile <> ‘analyst’ " but obviously this is not working well…
>Solution :
If I understood you correctly, that would be not exists. Something like this:
select *
from sr.v
where not exists (select null
from od.e_lds b
where b.niu_ld = t.niu_ld
and t.profile = 'Analyst'
);