question

vikas intel avatar image
vikas intel asked

How to make an average of data in sql server?

I have this data:

id time      act    ai   hr                    
1  3:26:00   null   5    4                    
2  3:26:00   null   5    4                    
3  3:27:00   7      null 4                    
4  3:27:00   6      5    4                    
6  3:27:00   null   5    4                    
7  3:28:00   null   5    4                    
8  3:28:00   null   5    4                    
9  4:26:00   null   5    4                    
10 4:36:00   null   5    4                    
11 5:26:00   6      5    4                    
12 5:36:00   null   5    4                    
13 5:46:00   null   5    null                    
14 6:26:00   null   5    4                    
15 7:26:00   null   null null                    

and I want the result like this:

id  time     act  ai  hr                    
1   3:26:00  5    9   8                    
2   3:26:00  null 5   4                    

and so on.

sql-server-2005aggregates
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Benjamin avatar image Benjamin commented ·
It's very hard to read your text when you don't apply formatting. In general, just GROUP BY your ID field and take the AVG of your data field. Can you apply the code formatting to your post and also provide the table schema?
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.