Vous êtes sur la page 1sur 12

Query 1. List out details of all employees who are born today SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.

last_name ,papf.email_address ,to_char(papf.date_of_birth,'DD-MON-YYYY') date_of_birth FROM per_all_people_f papf WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND to_char(date_of_birth,'DD-MON') = to_char(sysdate,'DD-MON'); Query 2. List out details of all employees who don t have valid email id with @ SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address FROM per_all_people_f papf WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND ( email_address IS NULL OR INSTR(email_address,'@') = 0 ); Query 3. List out details of Student Employees and Trainees SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,ppt.user_person_type Person_Type FROM per_all_people_f papf ,per_person_type_usages_f ptuf ,per_person_types ppt WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ date AND papf.current_employee_flag = 'Y' AND ptuf.person_id = papf.person_id AND TRUNC(sysdate) BETWEEN ptuf.effective_Start_date AND ptuf.effective_ end_date AND ppt.person_type_id = ptuf.person_type_id AND ppt.user_person_type IN ('Student','Trainee'); Query 4. List out details of all employees SELECT papf.employee_number ,papf.national_identifier

,papf.first_name ,papf.last_name ,papf.email_address ,ppt.user_person_type Person_Type FROM per_all_people_f papf ,per_person_type_usages_f ptuf ,per_person_types ppt WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND AND fective_end_date AND AND AND papf.current_employee_flag = 'Y' TRUNC(sysdate) BETWEEN ptuf.effective_Start_date AND ptuf.ef ptuf.person_id = papf.person_id ppt.person_type_id = ptuf.person_type_id ppt.system_person_type IN ('EMP');

Query 5. List out details all Ex-employees SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,ppt.user_person_type Person_Type FROM per_all_people_f papf ,per_person_type_usages_f ptuf ,per_person_types ppt WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND ptuf.person_id = papf.person_id AND TRUNC(sysdate) BETWEEN ptuf.effective_Start_date AND ptuf.ef fective_end_date AND ppt.person_type_id = ptuf.person_type_id AND ppt.system_person_type IN ('EX-EMP');

Query 6. List out details of all employees who joined in the current month with date of joining SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,to_char(pps.date_start,'DD-MON-YYYY') date_of_joining FROM per_all_people_f papf, per_periods_of_service pps WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ date AND papf.current_employee_flag = 'Y' AND pps.person_id = papf.person_id AND pps.date_start = ( SELECT

MAX(pps2.Date_Start) FROM per_periods_of_service pps2 WHERE pps2.person_id = papf.person_id AND pps2.date_start < = :g_effective_date ) AND to_char(pps.Date_Start,'MMYYYY') = to_char(sysdate,'MMYYYY'); Query 7. List out details of all employees terminated in the current month with date of joining and Termination Date SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,to_char(pps.date_start,'DD-MON-YYYY') date_of_joining ,to_char(pps.actual_termination_date,'DD-MON-YYYY') Termination_ Date FROM per_all_people_f papf, per_periods_of_service pps WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND pps.person_id = papf.person_id AND pps.Date_Start = ( SELECT MAX(pps2.Date_Start) FROM per_periods_of_service pps2 WHERE pps2.person_id = papf.person_id AND pps2.date_start < = :g_effective_date ) AND to_char(pps.actual_termination_date,'MMYYYY') = to_char(sysd ate,'MMYYYY'); Query 8. List out details of employees rehired in the current year SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,to_char(pps.date_start,'DD-MON-YYYY') Latest_Joining_Date ,to_char(papf.original_date_of_hire,'DD-MON-YYYY') First_emplmt_ start_date FROM per_all_people_f papf, per_periods_of_service pps WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND pps.person_id = papf.person_id AND pps.Date_Start = ( SELECT

MAX(pps2.Date_Start) FROM per_periods_of_service pps2 WHERE pps2.person_id = papf.person_id AND pps2.date_start < = :g_effective_date ) AND papf.original_date_of_hire <> pps.date_start d Condition AND to_char(pps.Date_Start,'YYYY') = to_char(sysdate,'YYYY'); Query 9. List out Employees with their Home Address SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,addr.address_type ,addr.address_line1 Home_Addr_Line_1 ,addr.address_line2 Home_Addr_Line_2 ,addr.address_line3 Home_Addr_Line_3 ,addr.town_or_city ,addr.Postal_code ,addr.region_1 county ,addr.region_2 state FROM per_all_people_f papf, per_addresses addr WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ date AND papf.current_employee_flag = 'Y' AND addr.person_id = papf.person_id AND addr.address_type like 'H' AND TRUNC(sysdate) BETWEEN addr.date_from and NVL( addr.date_to,to_date('31-Dec-4712','DD-Mon-YYYY') ) ORDER BY papf.employee_number,addr.date_from; Query 10. List out Employees having residence in California and MICHIGAN states SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,addr.address_line1 Home_Addr_Line_1 ,addr.address_line2 Home_Addr_Line_2 ,addr.address_line3 Home_Addr_Line_3 ,addr.town_or_city ,addr.Postal_code ,addr.region_1 county ,addr.region_2 state FROM per_all_people_f papf, per_addresses addr WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ --Rehire

date AND AND AND AND papf.current_employee_flag = 'Y' addr.person_id = papf.person_id addr.address_type = 'H' TRUNC(sysdate) BETWEEN addr.date_from and NVL( addr.date_to, to_date('31-Dec-4712','DD-Mon-YYYY')) AND addr.region_2 IN ('CA','MI'); Query 11. List out details of employees who does not have Primary Address SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address FROM per_all_people_f papf WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND NOT EXISTS ( SELECT 1 FROM per_addresses addr WHERE addr.person_id = papf.person_id AND addr.primary_flag = 'Y' AND TRUNC(sysdate) BETWEEN addr.date_from and NVL(addr.date_to, to_date('31-Dec-4712','DD-Mon-YYYY ')) ); Query 12. List out details of employees with Work and Mobile Phone numbers SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,wrk_Ph.phone_number Work_Phone ,mob_ph.phone_number mobile_phone FROM per_all_people_f papf, per_phones wrk_ph, per_phones mob_ph WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' -AND wrk_ph.phone_Type(+) = 'W1' AND wrk_ph.parent_table(+) = 'PER_ALL_PEOPLE_F' AND wrk_ph.parent_id(+) = papf.person_id AND TRUNC(sysdate) BETWEEN wrk_ph.date_from(+) and NVL( wrk_ph.date_to(+), to_date('31-Dec-4712','DD-Mo n-YYYY')) --

AND mob_ph.phone_Type(+) = 'M' AND mob_ph.parent_table(+) = 'PER_ALL_PEOPLE_F' AND mob_ph.parent_id(+) = papf.person_id AND TRUNC(sysdate) BETWEEN mob_ph.date_from(+) and NVL( mob_ph.date_to(+), to_date('31-Dec-4712','DD-Mon-YYYY ') );

Query 13. List out details of employees with their latest approved salary SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,to_char(ppp.change_date,'DD-MON-YYYY') change_date ,ppp.proposed_salary_N New_Salary FROM per_all_people_f papf, per_all_assignments_f paaf, per_pay_proposals ppp WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.effective_ end_date AND ppp.assignment_id = paaf.assignment_id AND ppp.approved = 'Y' AND ppp.change_date = ( SELECT MAX(ppp2.change_date) FROM per_pay_proposals ppp2 WHERE ppp2.assignment_id = paaf.assignment_id AND ppp2.approved = 'Y' AND ppp2.change_date <= trunc(sysdate) ); Query 14. List out details of employees whose salary change approval is pending SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,to_char(ppp.change_date,'DD-MON-YYYY') change_date ,ppp.proposed_salary_N New_Salary FROM per_all_people_f papf, per_all_assignments_f paaf, per_pay_proposals ppp WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ date AND papf.current_employee_flag = 'Y'

AND AND AND AND end_date

paaf.person_id = papf.person_id paaf.primary_flag = 'Y' paaf.assignment_type = 'E' TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.effective_

AND ppp.assignment_id = paaf.assignment_id AND nvl(ppp.approved,'N') = 'N' AND ppp.change_date = ( SELECT MAX(ppp2.change_date) FROM per_pay_proposals ppp2 WHERE ppp2.assignment_id = paaf.assignment_id AND nvl(ppp2.approved,'N') = 'N' AND ppp2.change_date <= trunc(sysdate) ); Query 15. List out details of employees not having Supervisor SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,'Manager Not Assigned' Missing_Reason FROM per_all_people_f papf, per_all_assignments_f paaf WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effective_end_ date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.effective_ end_date AND paaf.supervisor_id IS NULL; Query 16. List out details of Part Time employees with Weekly Hours >= 40 hrs SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,DECODE(paaf.employment_category ,'PR','Part Time Regular' ,'PT','Part Time Temporary' ) Employment_Category ,paaf.normal_hours weekly_hours FROM per_all_people_f papf, per_all_assignments_f paaf WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y'

AND AND AND AND fective_end_date AND AND

paaf.person_id = papf.person_id paaf.primary_flag = 'Y' paaf.assignment_type = 'E' TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef paaf.employment_category in ('PT','PR') paaf.normal_hours >= 40;

Query 17. List out details of employees with Organization Name and Cost Center SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,org.name Organization ,cost.segment3 cost_segment3 FROM per_all_people_f papf, per_all_assignments_f paaf, hr_all_organization_units org, pay_cost_allocation_keyflex cost WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef fective_end_date AND org.organization_id = paaf.organization_id AND cost.cost_allocation_keyflex_id = org.cost_allocation_keyfle x_id; Query 18. List out details of employees who are not eligible for Shift Allowance but eligible for Overtime (Assume Segment1 and 2 of the People Group stores Shift Eligibility and Overtime respectively) SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,ppg.segment1 Shift_Eligibility ,ppg.segment2 Overtime_Eligibility FROM per_all_people_f papf, per_all_assignments_f paaf, pay_people_groups ppg WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id

AND AND AND fective_end_date AND AND AND

paaf.primary_flag = 'Y' paaf.assignment_type = 'E' TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef ppg.people_group_id = paaf.people_group_id ppg.segment1 = 'N' ppg.segment2 = 'Y';

Query 19. List out details of non-exempt employees (Job >> Further Information > > FLSA Code stores EX for exempt, and NEX for non-exempt) SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,DECODE(pj.job_information3,'EX','Exempt','NEX','Non-exempt') Ex empt_Flag FROM per_all_people_f papf, per_all_assignments_f paaf, per_jobs pj WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef fective_end_date AND pj.job_id = paaf.job_id AND pj.job_information3 = 'NEX'; Query 20A. List out the details of employees to whom grade is not matching with the job CHALLENGE YOURSELF! Query 20B. List out the details of employees whose salary is below average salar y of the grade CHALLENGE YOURSELF! Query 21. List out details of employees in Long Term Leave status SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,past.user_status FROM per_all_people_f papf, per_all_assignments_f paaf, per_assignment_status_types past WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id

AND AND AND fective_end_date AND _id AND

paaf.primary_flag = 'Y' paaf.assignment_type = 'E' TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef past.assignment_status_type_id = paaf.assignment_status_type past.user_status = 'Long Term Leave';

Query 22. List out details of Hourly employees SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,ppb.name Salary_Basis FROM per_all_people_f papf, per_all_assignments_f paaf, per_pay_bases ppb WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef fective_end_date AND ppb.pay_basis_id = paaf.pay_basis_id AND ppb.name = '<Hourly Salary Basis Name>'; Query 23. List out details of employees working in CALIFORNIA State SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,loc.address_line_1 ,loc.address_line_2 ,loc.address_line_3 ,loc.town_or_city ,loc.postal_code ,loc.region_1 county ,loc.region_2 state FROM per_all_people_f papf, per_all_assignments_f paaf, hr_locations_all loc WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND AND AND AND papf.current_employee_flag = 'Y' paaf.person_id = papf.person_id paaf.primary_flag = 'Y' paaf.assignment_type = 'E'

AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef fective_end_date AND loc.location_id = paaf.location_id AND loc.region2 = 'CA'; Query 24. List out details of employees with GRE SELECT papf.employee_number ,papf.national_identifier ,papf.first_name ,papf.last_name ,papf.email_address ,org.name GRE_Name FROM per_all_people_f papf, per_all_assignments_f paaf, hr_soft_coding_keyflex hsck, hr_all_organization_units org WHERE TRUNC(sysdate) BETWEEN papf.effective_Start_date AND papf.effect ive_end_date AND papf.current_employee_flag = 'Y' AND paaf.person_id = papf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND TRUNC(sysdate) BETWEEN paaf.effective_Start_date AND paaf.ef fective_end_date AND hsck.soft_coding_keyflex_id = paaf.soft_coding_keyflex_id AND org.organization_id = hsck.segment1; Query 25A. List out supervisors hierarchy for an employee SELECT DISTINCT LPAD(' ',Level*10,'*') || e.FULL_NAME|| ','|| er Employee_Name FROM per_assignments_x a, per_people_x e, per_people_x s WHERE a.assignment_type = 'E' and a.primary_flag = 'Y' and e.person_id = a.person_id and s.person_id = a.supervisor_id CONNECT BY A.person_id = prior A.supervisor_id START WITH e.employee_number = '5714' ORDER BY level; Query 25B. List out all employees working under a supervisor SELECT DISTINCT Level,LPAD(' ',Level*10,'*') || E.FULL_NAME|| e_number Employee_Name FROM per_assignments_x a, per_people_x e, per_people_x s WHERE

e.employee_numb

','||

E.employe

a.assignment_type = 'E' and a.primary_flag = 'Y' and e.person_id = a.person_id and s.person_id = a.supervisor_id CONNECT BY prior A.person_id = A.supervisor_id START WITH e.employee_number = '181708'; Query 26. List out employees whose supervisor has left the company. Merge resul ts with results of query15 using union operator. CHALLENGE YOURSELF! Query 27. List out details of employee with Supervisor Name CHALLENGE YOURSELF! Query 28. List out details of employee with HR Generalist Name CHALLENGE YOURSELF! Query 29. List out details of Contact Relationships for the given employee Numbe r CHALLENGE YOURSELF! Query 30. List out details of employees with next salary/payment date CHALLENGE YOURSELF!

Vous aimerez peut-être aussi