Hello all,
I am trying to return multiple values for an EE on a single row. Example:
So I had it working and then I added another column and condition and it duplicated the EMPLOYID. Here is my script:
SELECT a.EMPLOYID, rtrim(a.FRSTNAME) + ' ' + a.LASTNAME as 'EMPLOYEE NAME', a.INACTIVE, a.BRTHDATE, c.STATE, c.ZIPCODE,
a.Primary_Pay_Record, UPR40301.DSCRIPTN AS JOBTITLE, b.BENEFIT, d.DEDUCTON as Spouse, e.DEDUCTON as Child, f.deducton as Voluntary,
b.BENEFIT as [Dental Benefit],
CASE
WHEN b.BENEFIT like 'LI%' THEN 'LI%'
WHEN d.DEDUCTON like 'LI%SPE' then 'LI%SPE'
WHEN e.DEDUCTON like 'LI%CHE' then 'LI%CHE'
when f.DEDUCTON like 'LI%' then 'LI%'
else ''
end
FROM UPR00100 a left outer join
UPR00600 b ON a.EMPLOYID = b.EMPLOYID left outer JOIN
UPR40301 ON a.JOBTITLE = UPR40301.JOBTITLE left outer join
UPR00102 c on a.EMPLOYID = c.EMPLOYID left outer join
UPR00500 d on a.EMPLOYID = d.EMPLOYID left outer join
UPR00500 e on a.EMPLOYID = e.EMPLOYID left outer join
UPR00500 f on a.EMPLOYID = f.EMPLOYID
WHERE ((b.INACTIVE = 0) AND (a.INACTIVE = 0) AND (c.STATE <> '')and (c.ZIPCODE <> '') and (b.BENEFIT LIKE 'LI%') and (d.DEDUCTON like 'LI%SPE')
and (e.DEDUCTON like 'LI%CHE') and (f.DEDUCTON like 'LI%'))
Any help would be greatly appreciated.
I am trying to return multiple values for an EE on a single row. Example:
So I had it working and then I added another column and condition and it duplicated the EMPLOYID. Here is my script:
SELECT a.EMPLOYID, rtrim(a.FRSTNAME) + ' ' + a.LASTNAME as 'EMPLOYEE NAME', a.INACTIVE, a.BRTHDATE, c.STATE, c.ZIPCODE,
a.Primary_Pay_Record, UPR40301.DSCRIPTN AS JOBTITLE, b.BENEFIT, d.DEDUCTON as Spouse, e.DEDUCTON as Child, f.deducton as Voluntary,
b.BENEFIT as [Dental Benefit],
CASE
WHEN b.BENEFIT like 'LI%' THEN 'LI%'
WHEN d.DEDUCTON like 'LI%SPE' then 'LI%SPE'
WHEN e.DEDUCTON like 'LI%CHE' then 'LI%CHE'
when f.DEDUCTON like 'LI%' then 'LI%'
else ''
end
FROM UPR00100 a left outer join
UPR00600 b ON a.EMPLOYID = b.EMPLOYID left outer JOIN
UPR40301 ON a.JOBTITLE = UPR40301.JOBTITLE left outer join
UPR00102 c on a.EMPLOYID = c.EMPLOYID left outer join
UPR00500 d on a.EMPLOYID = d.EMPLOYID left outer join
UPR00500 e on a.EMPLOYID = e.EMPLOYID left outer join
UPR00500 f on a.EMPLOYID = f.EMPLOYID
WHERE ((b.INACTIVE = 0) AND (a.INACTIVE = 0) AND (c.STATE <> '')and (c.ZIPCODE <> '') and (b.BENEFIT LIKE 'LI%') and (d.DEDUCTON like 'LI%SPE')
and (e.DEDUCTON like 'LI%CHE') and (f.DEDUCTON like 'LI%'))
Any help would be greatly appreciated.
//Jeff