Tuesday, October 27, 2009

Get list of employee's entitlement policys entitlements which have custom unit dates

select * from ENT_ENTITLEMENT
where ENT_ID in (
select ENT_ID from ENT_POLICY_ENTITLEMENT
where ENTPOL_ID in (
select ENTPOL_ID from ENT_EMP_POLICY
where EMP_ID = ?
and ENTEMPPOL_ENABLED = 'Y'
and ? between ENTEMPPOL_START_DATE and
ENTEMPPOL_END_DATE

)
and ? between ENTPOLENT_START_DATE and ENTPOLENT_END_DATE
)
and ? between ENT_START_DATE and ENT_END_DATE
and ENT_APPLY_ON_UNIT = 'CUSTOM'