Select
hr.res_id
,hr.fullname
,hr.usr_id
,jt.descr50
,hr.comp
,hr.job_title
,hr.loc
, cicmpy.cmp_fadd1 as address
, cicmpy.cmp_tel as phone
, cicmpy.cmp_fax as fax
, cicmpy.cmp_fcity COLLATE DATABASE_DEFAULT+ ', ' + cicmpy.statecode COLLATE DATABASE_DEFAULT+ ' ' + cicmpy.cmp_fpc COLLATE DATABASE_DEFAULT as citystate
,hr.ldatindienst
,hr.emp_stat
,hr.NewDiv --hr.costcenter
,a.itemcode
,i.userYesNo_01
,a.enddate
From
(
select *
,case when costcenter = '17-11F' then '011'
when costcenter = '17-12F' then '012'
when costcenter = '17-13F' then '013'
when costcenter = '17-14F' then '014'
when costcenter = '17-16F' then '016'
else 99 end as NewDiv
from humres
) as hr
left join (absences a inner join items i on i.itemcode = a.itemcode and i.userYesNo_01 = 1) on hr.res_id = a.empid and a.type = 86
left join hrjbtl as jt on hr.job_title = jt.job_title
--
left join cicmpy ON hr.comp= cicmpy.administration and cicmpy.cmp_type = 'D'
where usr_id = 'T0798'
--
Order by hr.res_id
|