Question

I have a table that has periodical values, with a 1 second period. Exemple:

DateTime                Value
2010/01/01 00:00:00     2
2010/01/01 00:00:01     4
2010/01/01 00:00:02     3
2010/01/01 00:00:03     1
2010/01/01 00:00:04     3
2010/01/01 00:00:05     4
2010/01/01 00:00:06     6
2010/01/01 00:00:07     1

I would like to know the SQL Request to get average values on a 2 seconds period, so the result would be:

DateTime                Value
2010/01/01 00:00:00     3
2010/01/01 00:00:02     2
2010/01/01 00:00:04     3.5
2010/01/01 00:00:06     3.5

How can I do that in SQL?

Thanks

EDIT: I use Microsoft SQL Server Express R2 2008

Was it helpful?

Solution

I finaly use stored procedure and create a temporary table so I can work with it. It works well. Thanks for the help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top