select employee
,min(case when plan_code='LSFS' then 1 else null end) as LSFS
,sum(case when plan_code='LSFS' then emp_cost else null end) as LSFS_COST
,min(case when plan_code='FSAM' then 1 else null end) as FSAM
,sum(case when plan_code='FSAM' then emp_cost else null end) as FSAM_COST
,min(case when plan_code='HSAV' then 1 else null end) as HSAV
,sum(case when plan_code='HSAV' then emp_cost else null end) as HSAV_COST
,min(case when plan_code='MED1' then 1 else null end) as MED1
,sum(case when plan_code='MED1' then emp_cost else null end) as MED1_COST
,min(case when plan_code='MED2' then 1 else null end) as MED2
,sum(case when plan_code='MED2' then emp_cost else null end) as MED2_COST
from bnben
where employee in (1666,1712)
and (plan_type='RS'
or plan_code in ('MEDW','MED1','MED4')
group by employee
order by employee
;