This works if your data is always 1 and 0.
Declare @table table(id int, colA int, colb int, colc int)
Insert into @table
Select
1 , 1 , 1 , 0
Union All
Select
2, 0 , 1 , 1
Union All
Select
3 , 0, 0 , 1
Union All
Select
4 , 1 , 1, 1
Union All
Select
5 , 1, 1 , 0
Select
Sum(cola)/Convert(Float, Count(id)),
Sum(colb)/Convert(Float, Count(id)),
Sum(Colc)/Convert(Float, Count(id))
From
@table
Will there ever be values other than 1 or 0? If so how do you know what value you are trying to find the percentage for?
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question