Friday, June 27, 2014

Query to Get All Active Employee Details.

SELECT papf.full_name "Full Name",
         papf.last_name "Last Name",
         papf.first_name "First Name",
         DECODE (papf.Person_Type_id,
                 '6', 'Emp',
                 '9', 'Ex-Emp',
                 '13', 'Cont')
            "Pers Type",
         papf.current_employee_flag "Current Emp Flag",
         papf.employee_number "Employee Number",
         papf.current_npw_flag "Current NPW Flag",
         papf.npw_number "NPW Number",
         b.d_job_id "Job Title",
         b.in_organization_flag "Internal",
         b.location_code "Location Code",
         b.office_site_flag "Office Site",
         b.d_supervisor_id "Supervisor",
         fu.user_name,
         fu.description "User Description",
         papf.email_address "User Email",
         fu.start_date "User Start"
    FROM apps.FND_USER fu,
         apps.PER_ALL_PEOPLE_F papf,
         apps.PER_ALL_ASSIGNMENTS_F asg,
         apps.PER_ASSIGNMENTS_V7 b,
         apps.HR_ALL_POSITIONS_F hapf,
         apps.HR_ALL_ORGANIZATION_UNITS haou,
         apps.PER_JOBS pjb
   WHERE (papf.person_id = asg.person_id(+) AND asg.person_id = b.person_id)
         AND b.effective_start_date = (SELECT MAX (b2.effective_start_date)
                                         FROM apps.per_assignments_v7 b2
                                        WHERE b2.person_id = b.person_id)
         AND SYSDATE BETWEEN papf.effective_start_date
                         AND papf.effective_end_date
         AND SYSDATE BETWEEN asg.effective_start_date
                         AND asg.effective_end_date
         AND asg.position_id = hapf.position_id(+)
         AND fu.employee_id(+) = papf.person_id
         AND haou.organization_id = asg.organization_id
         AND b.job_id = pjb.job_id(+)
ORDER BY papf.full_name;

No comments:

Post a Comment