Thursday, 15 May 2014

Query to Find All Active Employees and Current Salary

/* Formatted on 5/15/2014 9:47:25 AM (QP5 v5.115.810.9015) */
SELECT   EMPLOYEE_NUMBER,
         a.FULL_NAME,
         x.USER_PERSON_TYPE,
         c.PROPOSED_SALARY_n Basi_Salary,
         c.CHANGE_DATE
--         c.*
  FROM   per_people_f A,
         per_assignments_f b,
         pER_PAY_pROposals c,
         per_person_types x,
         per_person_type_usages_f e
 WHERE       a.PERSON_ID = b.PERSON_ID
         AND b.ASSIGNMENT_ID = C.ASSIGNMENT_ID
         AND a.EMPLOYEE_NUMBER IS NOT NULL
         AND a.EMPLOYEE_NUMBER = :emp_num
         AND c.CHANGE_DATE =
               (SELECT   MAX (d.CHANGE_DATE)
                  FROM   pER_PAY_pROposals d
                 WHERE   d.ASSIGNMENT_ID = b.ASSIGNMENT_ID
                         AND d.approved = 'Y')
         -- and c.CHANGE_DATE>=:change_date
         --AND b.PAYROLL_ID = 62
         AND:p_effective_date BETWEEN a.EFFECTIVE_START_DATE
                                  AND  a.EFFECTIVE_END_DATE
         AND:p_effective_date BETWEEN b.EFFECTIVE_START_DATE
                                  AND  b.EFFECTIVE_END_DATE
         AND a.PERSOn_id = e.PERSON_ID
         AND a.EFFECTIVE_START_DATE BETWEEN e.EFFECTIVE_START_DATE
                                        AND  e.EFFECTIVE_END_DATE
         AND e.PERSON_TYPE_ID = x.PERSON_TYPE_ID
         AND x.SYSTEM_PERSON_TYPE = 'EMP'

No comments:

Post a Comment