hi Everyone
My data ....
Employee_number, Segment, Business Unit, system_shortname and Auth_type
(employee_number, Segment where they work, Unit where they work, System they tried to access and authorisation method they used)
- The innermost query - I need to find distinct emp_number, system_short and Auth_type
WHERE
Response_code = 0. (this means an employee had an unsuccessful logon to the system and auth_type)
Then, for that innermost query I am looking for the same combination that DONT have any records where Response_code = 1. (Response_code 1 = successful access. )
Lastly I need to join that to the HR_table
My query currently looks like this, but I am not getting it right...In essence I want to find the guys that have at least ONE unsucessfull logon and have NEVER had a Successful access).
Please may you assist.
Thank you (PS I am using MySql)
Select upper(concat(hr.emp_number,'-',first_name,' ',surname)) as EMP_FULL,
hr.division,segment,business_unit,system_short,auth_type
From totus_hr.hr_ucn_staff_list hr
Inner join
(
select a.emp_number, a.system_short,a.auth_type
from totus_ods.groot_2fa_log a
inner join
(
select emp_number,system_short,auth_type
from
(
select emp_number, system_short,auth_type
from totus_ods.groot_2fa_log
group by 1,2,3
) x
group by 1,2,3
having count(*) = 1
) b on a.emp_number = b.emp_number and a.system_short = b.system_short and a.auth_type = b.auth_type
where response_code = 0
group by 1,2,3
) b on hr.emp_number = b.emp_number