Recently we had a requirement to include logic in SQL for retrieving employee information.

 Logic:

For populating HIRE Date in a view we need to use below logic:

 If UHC_ACQUISITION_DT is populated use CMPNY_SENIORITY_DT, else if REHIRE_DT is populated use REHIRE_DT.  If neither of those are populated use HIRE_DT

SQL Provided:

SELECT EMPLID , CASE WHEN UHC_ACQUISITION_DT IS  NOT NULL THEN CMPNY_SENIORITY_DT ELSE  CASE WHEN REHIRE_DT IS NOT NULL THEN REHIRE_DT ELSE HIRE_DT END END FROM PS_UHC_PERSONS where  emplid = ‘XXXXXXXXX’

 

Advertisements