Thursday, 15 May 2014

Employees who have a certain Element Entries with no values restrictions

/* Formatted on 5/15/2014 10:17:33 AM (QP5 v5.115.810.9015) */
  SELECT --Decode(asg.BUSINESS_GROUP_ID ,81,'DED',84,'DOH',120,'DCA',305,'DMD',346,'DIW',1456,'DPD',4507,'DTCM',4508,'DLD',4509,'DPD', 'New') DPT, --ppa.BUSINESS_GROUP_ID BG),
        asg.ASSIGNMENT_NUMBER Emp_Num --, pee.ELEMENT_ENTRY_ID-- -, asg.ASSIGNMENT_ID, pet.ELEMENT_TYPE_ID
                                     --,pep.ATTRIBUTE7 Emp_Num_DM
           ,
           TO_CHAR (pee.EFFECTIVE_START_DATE, 'dd/mm/yyyy') Effective_Date,
           pet.ELEMENT_NAME--, pee.SOURCE_ID
                           --, pee.CREATOR_TYPE
                           --,pet.PROCESSING_PRIORITY
                           --,piv.NAME Inupt
           ,
           peev.SCREEN_ENTRY_VALUE Days
    --Sum(peev.SCREEN_ENTRY_VALUE) Leave
    FROM   pay_element_types_f pet,
           pay_input_values_f piv,
           pay_element_entries_f pee,
           pay_element_entry_values_f peev,
           per_all_people_f pep,
           per_all_Assignments_f Asg,
           pay_element_links_f pel
   WHERE       1 = 1
           AND asg.business_group_id = 1456
           AND pet.business_group_id = asg.business_group_id
           AND pep.BUSINESS_GROUP_ID = asg.BUSINESS_GROUP_ID
           AND UPPER (pet.ELEMENT_NAME) LIKE UPPER ('ANNUAL LEAVE BAL ADJ') -- ('ANNUAL LEAVE BAL ADJ', 'ANNUAL LEAVE ACCRUAL RETRO')
           AND pet.element_type_id = pel.element_type_id
           AND pel.BUSINESS_GROUP_ID = asg.BUSINESS_GROUP_ID
           --and pet.CLASSIFICATION_ID in (96,110)
           AND pel.element_link_id = pee.element_link_id
           AND pee.Assignment_id = asg.Assignment_id
           --and asg.ASSIGNMENT_STATUS_TYPE_ID = 2  -- 1  Active         2  Suspended        3  Terminated
           AND pep.PERSON_ID = asg.PERSON_ID
           --and asg.ASSIGNMENT_NUMBER IN ('110045')
           AND TO_DATE ('1-2-2007', 'dd-mm-yyyy') BETWEEN asg.EFFECTIVE_START_DATE
                                                      AND  asg.EFFECTIVE_END_DATE
           AND SYSDATE BETWEEN pep.EFFECTIVE_START_DATE
                           AND  pep.EFFECTIVE_END_DATE
           AND pee.ELEMENT_ENTRY_ID = peev.ELEMENT_ENTRY_ID
           AND peev.INPUT_VALUE_ID = piv.INPUT_VALUE_ID
           --and Upper(piv.name) like  upper('%Days')
           --and piv.UOM = 'N'
           AND peev.SCREEN_ENTRY_VALUE IS NOT NULL
           AND peev.SCREEN_ENTRY_VALUE != '0'
--and to_date('01-6-2006','dd-mm-yyyy') between pee.EFFECTIVE_START_DATE and pee.EFFECTIVE_END_DATE
--and pee.EFFECTIVE_START_DATE between  to_date('01-1-2000','dd-mm-yyyy')  and to_date('1-6-2006','dd-mm-yyyy')
GROUP BY   asg.ASSIGNMENT_NUMBER, pep.ATTRIBUTE7

No comments:

Post a Comment