Crystal Reports Leave Liability
SELECT e.display_employee, e.first_name, e.last_name, e.display_employee empid,
e.other_string3 employee_type, e.other_number3,
e.other_number1 salary, e.full_time_equiv_pct fte, sy.other_number1 serviceyears,
sum(case when bos.bank='DRI_ANNUAL'
then bos.balance
else 0
end) AL,
sum(case when bos.bank='T_SICK'
then bos.balance
else 0
end) SL
from bank_output_summary bos, employee_periods ep, employee e, ld10 sy
where bos.employee_period_version = ep.calc_emp_period_version
and e.employee = ep.employee
and e.display_employee = sy.ld1
and {?STD_AS_OF_DATE_SQL} between ep.pp_begin and ep.pp_end
and {?STD_AS_OF_DATE_SQL} between e.eff_dt and e.end_eff_dt
and {?STD_AS_OF_DATE_SQL} between sy.eff_dt and sy.end_eff_dt
and (' All' in ({?DRI_EMPLOYEE_TYPE_SQL}) or e.other_string3 in ({?DRI_EMPLOYEE_TYPE_SQL}))
and (e.status_code1 = N'A' OR (e.status_code1 != N'A' AND e.status_date1 = bos.work_dt))
AND e.other_string3 NOT IN ('Hourly', 'Grad', 'TmpProf', 'TmpTech')
and bos.bank in (
select record_key from rule_set rs,
rule_set_detail rsd
where rs.rule_set = rsd.rule_set
and {?STD_AS_OF_DATE_SQL} between rs.eff_dt and rs.end_eff_dt
and rs.source_table = 'BANK'
and rs.rule_set = 'DRI_LEAVE_LIABILITY'
)
and bos.work_dt = (
select max(bos2.work_dt)
from bank_output_summary bos2
where bos.bank = bos2.bank
and bos2.employee_period_version = ep.calc_emp_period_version
and bos2.work_dt <= {?STD_AS_OF_DATE_SQL}
)
GROUP BY e.display_employee, e.first_name, e.last_name, e.display_employee, e.other_string3,
e.other_number1,e.other_number3, e.full_time_equiv_pct, sy.other_number1