SQL: To check whether age is greater than 26.



The Below SQL is useful to calculate the employee age who are having greater than 26 years:

 AND (PER.RELATIONSHIP IN('X','XN')
    OR ((TRUNC((to_number(TO_CHAR(%CurrentDateIn ,'yyyymmdd'))-to_number(TO_CHAR(PER.BIRTHDATE ,'yyyymmdd')))/10000)) > 26
   AND PER.DISABLED ='N' AND PER.RELATIONSHIP ='C' ) )


 AND

(

   PER.RELATIONSHIP IN('X','XN')  OR
   ((TRUNC((to_number(TO_CHAR(%CurrentDateIn ,'yyyymmdd'))-to_number(TO_CHAR(PER.BIRTHDATE ,'yyyymmdd')))/10000)) > 26

   AND PER.DISABLED ='N'   AND PER.RELATIONSHIP ='C' )

    OR (PLN.COVERAGE_ELECT='T'  AND PLN.COVERAGE_BEGIN_DT <= %Bind(IIE_WEEK_RUN_DATE))

)



AND (


   PER.RELATIONSHIP IN('X','XN')
 
OR (

(

(TRUNC((to_number(TO_CHAR(%CurrentDateIn ,'yyyymmdd'))-to_number(TO_CHAR(PER.BIRTHDATE ,'yyyymmdd')))/10000)) > 26
   AND PER.DISABLED ='N'
   AND PER.RELATIONSHIP ='C' )  OR (PLN.COVERAGE_ELECT='T' AND PLN.COVERAGE_BEGIN_DT <= %Bind(IIE_WEEK_RUN_DATE)

)

Comments

Popular posts from this blog

BI Publisher: If Condition with sub-string in rtf template