I would like your help because I made a simple query that would need to return all the records specified in the IN clause. In this clause IN (TF.CodTreina IN) is coming from a select. The problem is that it is returning some employees who have some training. What I need is to show only employees who have the training specified in the IN clause. The detail is the employee can not be the area that will be coming from the filter, for example area code 1, because I want to show the substitutes.
SELECT
FA.MatriculaSese,
TF.CodTreina,
TF.Data,
TF.Status,
FA.CentroCusto
FROM treina_func TF
INNER JOIN func_area FA
ON TF.MatriculaSese = FA.MatriculaSese
WHERE FA.CentroCusto <> 1
AND TF.CodTreina IN (
SELECT TA.CodTreina FROM treina_area TA WHERE TA.CodArea = 1
)
Trying to explain better. The problem being that is that you would select which returns only employees who have all the training in the IN clause. The training codes for area 1 are IN (1,16,32,64,122,136,168,169,170,171, 198, 199) I would like the select to return all employees who have exactly all of these training. In the code entered this is returning employees who have one another and not all. Is there anything that would only return employees who have all the training in the IN clause?
Gentlemen remaking and my doubt I think that now it will become clearer
SELECT * FROM vw_treina_func TF WHERE TF.CodTreina IN (1,16,22,33,75,97,110,115,158,161,164,173)
I would like this select to show employees who have all these trainings and not another one like this happening.