Here, I need data 'Eac_Card_Number' from another table 'Acc_Emp_AccessCard acc'
where emp.emp_id = acc.Eac_EmpId and max(acc.Eac_startDate).
How to integrate this condition in below query:
Select CASE
WHEN gen.Category_Name = 'Male' THEN 'Mr'
WHEN gen.Category_Name = 'Female' THEN 'Ms'
END as Emp_Salutation
,l.Login_Id as LgInfo_Nt_Login_Id
,org.Category_Name as emp_Organisation
,gen.Category_Name as emp_gender_id
,emp.Emp_category
,emp.emp_id
from prj_employee_detail emp
left join prj_category gen on emp.emp_gender_id = gen.Category_Id
left join prj_category org on emp.emp_Organisation = org.Category_Id
left join Prj_Login_Info l on emp.emp_id=l.LgInfo_Resource_Id
where l.lginfo_client_id = 0 and emp.emp_number not in ('0','')