У меня следующий запрос SQL, чтобы исключить сотрудников из отдела 'Post Closing'. Но я все еще собираю людей в отделе после закрытия. not exists
, похоже, не работает.
select concat(ltrim(rtrim(FirstName)), ' ',ltrim(rtrim(LastName))) Employee
from employeelist t1
where Department_Desc like '%Closing' or Department_Desc like '%Funding'
and (Position like 'A1%' or position like 'A2%')
and not exists(select concat(ltrim(rtrim(FirstName)), ' ',ltrim(rtrim(LastName))) Employee
from employeelist t2
where t1.Employee_Code = t2.Employee_Code
and t2.Department_Desc in ('Post Closing' ))
Любая помощь в решении этой проблемы будет принята с благодарностью.