Friday, July 3, 2015

Query: People





select
    ppf.employee_number       "Employee Number",
--
    ppf.last_name             "Last Name",
    ppf.first_name            "First Name",
    ppf.title                 "Title",
    ppf.pre_name_adjunct      "Prefix",
    ppf.suffix                "Suffix",
    ppf.middle_names          "Middle",
    decode(ppf.sex,
           'M','Male',
           'F','Female',
           ppf.sex)             "Gender",
    ppttl.user_person_type      "Person Type",
    ppf.applicant_number        "Applicant Number",
    ppf.national_identifier     "Social Security",
    ppf.effective_start_date    "Effective Date - From",
    ppf.effective_end_date      "Effective Date - To",
    ppf.start_date              "Latest Start Date",
    --
    ppf.date_of_birth         "Personal: Birth Date",
    ppf.town_of_birth         "Personal: Town Of Birth",
    ppf.region_of_birth       "Personal: Region of Birth",
    ppf.country_of_birth      "Personal: Country of Birth",
    trunc((sysdate -
      ppf.date_of_birth)/365) "Personal: Age",
    hl1.meaning               "Personal: Status",                
    ppf.nationality           "Personal: Nationality",
    hl2.meaning               "Personal: Registered Disabled",
    --
    hl5.meaning                         "Employment:Ethnic Origin",
    decode(ppf.per_information11,
        'N','No',
        'Y','Yes',
        ppf.per_information11)          "Employment:Ethnicity Disclosed",
    hl6.meaning                         "Employment:VETS100",
    decode(ppf.per_information9,
        'N','No',
        'Y','Yes',
        ppf.per_information9)           "Employment:Child Support",
    decode(ppf.per_information10,
        'N','No',
        'Y','Yes',
        ppf.per_information10)          "Employment:Opted for Medicare",
    decode(ppf.per_information2,
        'N','No',
        'Y','Yes',
        ppf.per_information2)           "Employment:I-9 Status",
    ppf.per_information3                "Employment:I-9 Expiration",
    hl7.meaning                         "Employment:New Hire",
    hl9.meaning                         "Employment:Exception Reason",
    hl8.meaning                         "Employment:Vets 100A",
    ppf.office_number              "Office Details: Office",
    ppf.internal_location          "Office Details:Location",
    ppf.mailstop                   "Office Details:MailStop",
    ppf.email_address              "Office Details:Email Address",
    hl1.meaning                    "Office Details:Mail To",
    ppf.resume_exists              "Applicant:Resume Exists",
    ppf.resume_last_updated        "Applicant:Last Updated",
    ppf.hold_applicant_date_until  "Hold Application Until",
    ppf.background_check_status    "Background:Checked",
    ppf.background_date_check      "Background:Date Checked",
    ppf.rehire_recommendation      "Rehire:Recommendation",
    ppf.rehire_reason              "Rehire:Reason",
    ppf.honors                     "Further Name:Honors",
    ppf.known_as                   "Further Name:Preferred Name",
    ppf.previous_last_name         "Previuos Last Name",
    hl3.meaning                    "Medical: Blood Type",
    ppf.last_medical_test_date     "Medical:Last Test Date",
    ppf.last_medical_test_by       "Medical:Last Test By",
    ppf.work_schedule              "Other:Work Schedule",
    ppf.fte_capacity               "Other:Full Time Availability",
    ppf.correspondence_language    "Correspondance language",
    ppf.date_of_death              "Date of Death",
    ppf.student_status             "Other:Student Status",
    ppf.date_employee_data_verified  "Other:Date Last Verified",
    ppf.on_military_service          "Other:On Military Service",
    ppf.second_passport_exists       "Other:Second Passport Exist",
    bbg.name                         "Benifits:Benifit Group",
    ppf.uses_tobacco_flag            "Benifits:Uses Tobacco",
    ppf.coord_ben_med_pln_no         "Benifits:Medical Plan",
    ppf.dpdnt_adoption_date          "Benifits:Adoption Date",
    ppf.receipt_of_death_cert_date   "Date Received Death Cert",
    pps.adjusted_svc_date            "Benifits:Adjusted Service Date" ,
    ppf.original_date_of_hire        "Benifits:Original Date Of Hire",
    ppf.coord_ben_no_cvg_flag        "Benifits:Other Coverage",
    ppf.dpdnt_vlntry_svce_flag       "Benifits:Voluntary Service",
    --
    ppf.person_id
from
    per_people_f ppf,
    per_person_types ppt,
    per_person_types_tl ppttl,
    hr_lookups hl1,
    hr_lookups hl2,
    ben_benfts_grp bbg,
    per_periods_of_service pps,
    hr_lookups hl11,
    hr_lookups hl12,
    hr_lookups hl3,
    hr_lookups hl4,
    hr_lookups hl5,
    hr_lookups hl6,
    hr_lookups hl7,
    hr_lookups hl8,
    hr_lookups hl9
where
    1=1
and ppt.person_type_id = ppf.person_type_id
and ppt.person_type_id = ppttl.person_type_id
and bbg.benfts_grp_id(+) = ppf.benefit_group_id
and pps.person_id(+) = ppf.person_id
and hl1.lookup_type(+) = 'STUDENT_STATUS'
and hl1.lookup_code(+) = ppf.student_status
and hl2.lookup_type(+) = 'REGISTERED_DISABLED'
and hl2.lookup_code(+) = ppf.registered_disabled_flag
and hl11.lookup_type(+) = 'HOME_OFFICE'
and hl11.lookup_code(+) = ppf.expense_check_send_to_address
and hl12.lookup_type(+) = 'WORK_SCHEDULE'
and hl12.lookup_code(+) = ppf.work_schedule
and hl3.lookup_type(+) = 'BLOOD_TYPE'
and hl3.lookup_code(+) = ppf.blood_type
and hl4.lookup_type(+) = 'STUDENT_STATUS'
and hl4.lookup_code(+) = ppf.student_status
and hl5.lookup_type(+) = 'US_ETHNIC_GROUP'
and hl5.lookup_code(+) = ppf.per_information1
and hl6.lookup_type(+) = 'US_VETERAN_STATUS'
and hl6.lookup_code(+) = ppf.per_information5
and hl7.lookup_type(+) = 'US_NEW_HIRE_STATUS'
and hl7.lookup_code(+) = ppf.per_information7
and hl8.lookup_type(+) = 'US_VETERAN_STATUS'
and hl8.lookup_code(+) = ppf.per_information25
and hl9.lookup_type(+) = 'US_NEW_HIRE_EXCEPTIONS'
and hl9.lookup_code(+) = ppf.per_information8
and ppttl.language = userenv ('LANG')
--
and ppf.employee_number = '1309'
order by
    1,2,3,4

Query: People Fedral Tax Rules





select
    ppf.employee_number                                         "Employee Number",
    --
    (select state_name
        from pay_us_states
        where state_abbrev = add_information17)               "Resident",
    (select hlat.region_2
       from hr_locations_all hlat
      where hlat.location_id = paaf.location_id)              "Work",
    pus.state_name                                            "SUI State",
    paa.add_information18                                     "Resident City",
    pus.state_name                                            "Work City",
    paa.add_information19                                     "Resident County",
     (select hlat.region_1
       from hr_locations_all hlat
      where hlat.location_id = paaf.location_id)               "Work County",
    hrl1.meaning                                              "Filing Status",
    ftr.withholding_allowances                                 "Allowances",
    ftr.fit_additional_tax                                     "Additional Tax",
    ftr.fit_exempt                                             "Tax Exemption :Fit",
    ftr.futa_tax_exempt                                        "Tax Exemption :FUTA",
    ftr.medicare_tax_exempt                                    "Tax Exemption :MEDICARE",
    ftr.ss_tax_exempt                                          "Tax Exemption :SS",
    ftr.fit_override_amount                                   "FO:Regular Amount",
    ftr.fit_override_rate                                     "FO:Regular Rate",
    ftr.supp_tax_override_rate                                 "FO:Supplemental Rate",
    ftr.excessive_wa_reject_date                               "Lock in Date",
    ftr.statutory_employee                                     "Statutory Employee",
    ftr.cumulative_taxation                                    "Cumulative Taxation",
    ftr.wage_exempt                                            "FIt Exempt Wage Acc",
    hrl2.meaning                                               "EIC filling status",
    ftr.effective_start_date                                  "Effec Dates: From",
    decode (ftr.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
    ftr.effective_end_date)                                   "Effec Dates: To",
    --
    ftr.emp_fed_tax_rule_id,
    paaf.assignment_id,
    paaf.location_id,
    paa.address_id
    --
from
    pay_us_emp_fed_tax_rules_f ftr,
    per_all_assignments_f paaf,
    pay_us_states pus,
    per_addresses paa,
    hr_lookups hrl1,
    hr_lookups hrl2,
    per_people_f ppf
where  
    ftr.sui_state_code = pus.state_code
and ftr.assignment_id=paaf.assignment_id
and paa.person_id=paaf.person_id
and ftr.filing_status_code = hrl1.lookup_code
and hrl1.lookup_type = 'US_FIT_FILING_STATUS'
and ftr.eic_filing_status_code = hrl2.lookup_code
and hrl2.lookup_type = 'US_EIC_FILING_STATUS'
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and ftr.assignment_id = paaf.assignment_id
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;

Query: People State Tax Rules





select
    ppf.employee_number                                         "Employee Number",
    --
    pus.state_name                                             "State",
    hrl.meaning                                                "W4 Info :Filing Status",
    str.withholding_allowances                                 "W4 Info :Allowances",
    str.secondary_wa                                           "W4 Info: Secon Allowances",
    str.additional_wa_amount                                   "W4 Info:Exemption Aaount",
    str.sit_additional_tax                                     "W4 Info:Addn Tax",
    str.sit_optional_calc_ind                                  "W4 Info :Opt Calc" ,
    str.sit_exempt                                             "Tax Ex: SIT",
    str.sdi_exempt                                             "Tax Ex: SDI",
    str.sui_exempt                                             "Tax Ex: SUI",
    str.wc_exempt                                              "Tax Ex: WC",
    str.sit_override_rate                                      "SIT Override:Regular Rate",
    str.sit_override_amount                                    "SIT Override:Regular Amount",
    str.supp_tax_override_rate                                 "SIT Override: Supp Rate",
    str.sui_wage_base_override_amount                          "SUI Base Override",
    str.excessive_wa_reject_date                               "Lock in Date",
    str.state_non_resident_cert                                "Non Resi Certi",
    str.wage_exempt                                            "SIT Exm Fm Wg Accm",
    str.effective_start_date                                   "Effective Date : From",
    decode (str.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
    str.effective_end_date)                                    "Effective Date: To",
    --
    str.assignment_id,
    str.business_group_id
    --
from
    pay_us_emp_state_tax_rules_f str,
    pay_us_states pus,
    pay_state_rules psr,
    hr_lookups hrl,
    per_all_assignments_f paaf,
    per_people_f ppf
where    
    pus.state_code = str.state_code
and psr.state_code = pus.state_abbrev
and hrl.lookup_type = psr.fs_lookup_type
and nvl(str.effective_end_date,sysdate)>sysdate-1
and hrl.lookup_code = ltrim (str.filing_status_code, '0')
and str.assignment_id = paaf.assignment_id
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;         

Query: People County Tax Rules




select
    ppf.employee_number                               "Employee Number",
    --
    pus.state_name                                    "State",
    puc.county_name                                   "County",
    hrl.meaning                                       "W4 Info: Filing Status",
    ctr.withholding_allowances                        "W4 Info: Allowances",
    ctr.lit_additional_tax                            "W4 Info: Additional Tax",
    ctr.additional_wa_rate                            "W4 Info:Add Alllow Rate",
    ctr.lit_exempt                                    "Tax Ex:Local Income",
    ctr.sd_exempt                                     "Tax Ex:School District",
    ctr.ht_exempt                                     "Tax Ex: Occu Privilage",
    ctr.lit_override_rate                             "LIT Override: Rate",
    ctr.lit_override_amount                           "LIT Override: Amount",
    psd.school_dst_name                               "School District",
    ctr.wage_exempt                                   "LIT Ex from Wge Accu",
    ctr.effective_start_date                          "Effective Dates: From",
    decode (ctr.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
    ctr.effective_end_date)                           "Effective Dates: To",
    --
    ctr.assignment_id
from
    pay_us_emp_county_tax_rules_f ctr,
    pay_us_states pus,
    pay_us_counties puc,
    hr_lookups hrl,
    pay_us_county_school_dsts psd,
    per_all_assignments_f paaf,
    per_people_f ppf
where  
    1=1
and ctr.state_code = pus.state_code
and ctr.state_code = puc.state_code
and ctr.county_code = puc.county_code
and ctr.filing_status_code = hrl.lookup_code
and hrl.lookup_type = 'US_LIT_FILING_STATUS'
and ctr.state_code = psd.state_code(+)
and ctr.county_code = psd.county_code(+)
and ctr.school_district_code = psd.school_dst_code(+)
and ctr.assignment_id = paaf.assignment_id
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;

Query: People City Tax Rules





select
    ppf.employee_number                                         "Employee Number",
    --
    pus.state_name                                             "State",
    pucnty.county_name                                         "County",
    pucity.city_name                                           "City",
    hrl.meaning                                                "W4 Info: Filing Status",
    ctr.withholding_allowances                                 "W4 Info: Allowances",
    ctr.lit_additional_tax                                     "W4 Info: Additional Tax",
    ctr.additional_wa_rate                                     "W4 Info: Additional All Rate",
    ctr.lit_exempt                                             "Tax Exn:Local Income",
    ctr.sd_exempt                                              "Tax Exn:School District",
    ctr.ht_exempt                                              "Tax Exn: Occupational Pri",
    ctr.lit_override_rate                                      "LIT Override:Rate",  
    ctr.lit_override_amount                                    "LIT Override:Amount",
    psd.school_dst_name                                        "School District",
    ctr.wage_exempt                                            "LIT Exmp From Wage Accn",
    ctr.effective_start_date                                   "Effective Dates: From",
    decode (ctr.effective_end_date,
    to_date ('31124712', 'DDMMYYYY'), null,
                  ctr.effective_end_date)                      "Effective Dates: To",
    --
    ctr.business_group_id,
    ctr.emp_city_tax_rule_id,
    ctr.assignment_id
    --
from
    pay_us_emp_city_tax_rules_f ctr,
    pay_us_states pus,
    pay_us_counties pucnty,
    pay_us_city_names pucity,
    hr_lookups hrl,
    pay_us_city_school_dsts psd,
    per_all_assignments_f paaf,
    per_people_f ppf
where
    ctr.state_code = pus.state_code
and ctr.state_code = pucnty.state_code
and ctr.county_code = pucnty.county_code
and ctr.state_code = pucity.state_code
and ctr.county_code = pucity.county_code
and ctr.city_code = pucity.city_code
and (pucity.primary_flag = 'Y' or substr (pucity.city_code, 1, 1) = 'U')
and ctr.filing_status_code = hrl.lookup_code
and hrl.lookup_type = 'US_LIT_FILING_STATUS'
and ctr.state_code = psd.state_code(+)
and ctr.county_code = psd.county_code(+)
and ctr.city_code = psd.city_code(+)
and ctr.school_district_code = psd.school_dst_code(+)
and ctr.assignment_id = paaf.assignment_id
and nvl(paaf.effective_end_date,sysdate)>sysdate-1
and paaf.person_id = ppf.person_id
--
and ppf.employee_number='1309'
order by
      1,2;

Query: Job Work Preferences




select
    pjt.name                         "Job",
    --
    pdf.work_any_location            "All Locations",
    pdf.passport_required            "Passport Required",
    pdf.relocation_required          "Relocation Required",
    pdf.relocate_domestically        "Relocation for Position",
    pdf.travel_required              "Travel Required",
    pdf.work_duration                "Work Duration",
    pdf.work_hours                   "Work Hours",
    pdf.service_minimum              "Minimum Service",     -- lookup :per_lengths_of_service
    pdf.work_schedule                "Work Schedule",       -- lookup :per_work_schedule
    pdf.fte_capacity                 "FTE Capacity",        -- lookup :per_work_hours
    pdf.work_any_country             "All Countries",
    pdf.relocate_internationally     "Willing to Relocate ",
    pdf.other_requirements           "Required Locations",
    ptv1.territory_short_name        "Rquired Countries1",
    hrl1tl.location_code             "Location1",
    ptv2.territory_short_name        "Rquired Countries2",
    hrl2tl.location_code             "Location2",
    ptv3.territory_short_name        "Rquired Countries3",
    hrl3tl.location_code             "Location3",
    --
    pj.job_id
from
    per_deployment_factors pdf,
    per_jobs pj,
    per_jobs_tl pjt,
    fnd_territories_vl ptv1,
    fnd_territories_vl ptv2,
    fnd_territories_vl ptv3,
    hr_locations_no_join hrl1,
    hr_locations_no_join hrl2,
    hr_locations_no_join hrl3,
    hr_locations_all_tl hrl1tl,
    hr_locations_all_tl hrl2tl,
    hr_locations_all_tl hrl3tl
where
    1=1
and pdf.job_id = pj.job_id
and pj.job_id = pjt.job_id
and pjt.language = userenv('LANG')
and ptv1.territory_code(+) = pdf.country1
and ptv2.territory_code(+) = pdf.country2
and ptv3.territory_code(+) = pdf.country3
and hrl1.location_id(+) = pdf.location1
and hrl2.location_id(+) = pdf.location2
and hrl3.location_id(+) = pdf.location3
and hrl1.location_id = hrl1tl.location_id(+)
and hrl2.location_id = hrl2tl.location_id(+)
and hrl3.location_id = hrl3tl.location_id(+)
and decode (hrl1tl.location_id, null, '1', hrl1tl.language) = decode (hrl1tl.location_id, null, '1', userenv ('LANG'))
and decode (hrl2tl.location_id, null, '1', hrl2tl.language) = decode (hrl2tl.location_id, null, '1', userenv ('LANG'))
and decode (hrl3tl.location_id, null, '1', hrl3tl.language) = decode (hrl3tl.location_id, null, '1', userenv ('LANG'))
--
and pjt.name = 'AA900.Administrative Assistant'
order by
    1,2,3;

Query: Contracts




select
    per.employee_number                                                              "Employee Number",
    --
    per.full_name                                                                    "Full Name",
    con.reference                                                                    "Contract Reference",
    asg.assignment_number                                                            "Assignment Number",
    hr_person_type_usage_info.get_user_person_type (sysdate,per.person_id)           "Person Type",
    per.applicant_number                                                             "Applicant Number",
    pps.date_start                                                                   "Hire Date",
    substr (hr_general.decode_lookup('CONTRACT_TYPE', con.type), 1, 80)              "Contract Type",  
    substr (hr_general.decode_lookup('CONTRACT_STATUS', con.status),1,80)            "Contract Status",
    substr ( hr_general.decode_lookup('CONTRACT_STATUS_REASON',con.status_reason),1,80) "Contract Status Reason",
    con.description                                                                     "Contract Description",
    con.duration                                                                        "Duration",
    substr ( hr_general.decode_lookup ('QUALIFYING_UNITS',con.duration_units), 1,80)    "Duration Units",
    con.contractual_job_title                                                           "Contractual Job Title",
    con.parties                                                                         "Parties",
    substr (hr_general.decode_lookup ('CONTRACT_START_REASON',con.start_reason),1,80)   "Start Reason",
    substr (hr_general.decode_lookup ('CONTRACT_END_REASON',con.end_reason),1,80)       "End Reason",
    con.number_of_extensions                                                            "Number of Extensions",
    con.extension_reason                                                                "Extension Reason",
    con.extension_period                                                                "Extension Period",
    substr (hr_general.decode_lookup ('QUALIFYING_UNITS',con.extension_period_units),1,80)  "Extension Period Units",
    greatest (con.effective_start_date, per.effective_start_date)                   "Effective Start Date",
    least (con.effective_end_date, per.effective_end_date)                          "Effective End Date",
     substr( hr_general.decode_lookup ('DOCUMENT_STATUS',con.doc_status),1,80)      "Document Status",
    con.doc_status_change_date                                                      "Date of Change",
    fnd_attachment_util_pkg.get_atchmt_exists ('PER_CONTRACTS',
                             con.contract_id,null,null,null,null,
                            'PERWSCTR','O')                                         "Attachment Exists",
    --
    asg.people_group_id,
    per.business_group_id,
    per.person_id
from
    per_people_f per,
    per_assignments_f asg,
    per_person_types ppt,
    per_periods_of_service pps,
    per_contracts_f con,
    per_business_groups bg
where
    con.person_id(+) = per.person_id
and pps.person_id = per.person_id
and asg.person_id = per.person_id
and asg.assignment_type in ('E','C')
and ppt.person_type_id = per.person_type_id
and sysdate between asg.effective_start_date and asg.effective_end_date
and sysdate between per.effective_start_date and per.effective_end_date
and per.business_group_id = bg.business_group_id
--
and bg.name = 'Vision Corporation'
and per.employee_number='388'
order by
    1,2,3,4;