x

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.

more ▼

asked Oct 31, 2009 at 01:02 PM in Default

avatar image

vikas intel
11 2 2 2

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?

Oct 31, 2009 at 03:53 PM Benjamin
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2017
x70

asked: Oct 31, 2009 at 01:02 PM

Seen: 849 times

Last Updated: Nov 03, 2009 at 10:55 AM

Copyright 2016 Redgate Software. Privacy Policy