Click here to Skip to main content
15,920,602 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Facid Feedbackid FacQ1 FacQ2
1 1 5 4
2 1 4 3
3 1 4 2
1 2 5 4
2 2 4 2
3 2 4 3

Total 26 18

i want to sum the Facq1,FacQ2 and divide by number of rows.

I want output as follows

Feedbackid Average

1 4.3 (26/6 = 4.3)
2 3 (18/6 = 3)
Posted

SQL
select  CAST(sum(FacQ1)AS float)/count(*) , CAST(Sum(FacQ2)AS float)/count(*) from YourTable
 
Share this answer
 
v2
try this.. :)


SQL
select convert(float,sum(FacQ1))/count(*) as avg1,convert(float,sum(FacQ2))/count(*) as avg2 from TableName
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900