Here's another brute-force attack using a subquery. Setting up some test data:
CREATE TABLE MyTable
(
Id int not null
,Col1 char(1) null
,Col2 char(1) null
,Col3 char(1) null
,Col4 char(1) null
)
INSERT MyTable
select 1, 'Y', 'Y', 'Y', 'Y'
union all select 2, 'Y', null, 'N', null
union all select 3, 'Y', null, null, null
union all select 4, null, null, null, null
I used character data for the target value, but you should have no problems making it numeric. I added a fourth line to check for divide by zeros (thanks ps!). So,
SELECT
mt.ID
,case mt.Col1 when 'Y' then xx.distrib else 0 end
,case mt.Col2 when 'Y' then xx.distrib else 0 end
,case mt.Col3 when 'Y' then xx.distrib else 0 end
,case mt.Col4 when 'Y' then xx.distrib else 0 end
from MyTable mt
inner join (select
ID
,1.0 / ( case Col1 when 'Y' then 1 else 0 end
+ case Col2 when 'Y' then 1 else 0 end
+ case Col3 when 'Y' then 1 else 0 end
+ case Col4 when 'Y' then 1 else 0 end) distrib
from MyTable) xx
on xx.Id = mt.Id
appears to produce the desired results. (Run the subquery on its own and you get a divide by zero... but I honestly have no idea why running the whole query does not.