views:

40

answers:

3

Hello,

I have a table with a 'timestamp' column and a 'value' column where the values are roughly 3 seconds apart.

I'm trying to return a table that has daily average values.

So, something like this is what i'm looking for.

| timestamp  | average |

| 2010-06-02 |  456.6  |

| 2010-06-03 |  589.4  |

| 2010-06-04 |  268.5  |

etc...

Any help on this would be greatly appreciated.

+1  A: 

This assumes that your timestamp column only contains information about the day, but not the time. That way, the dates can be grouped together:

select timestamp, AVG(value) as average
from TABLE_NAME
group by timestamp
Kevin Crowell
I don't think he actually has discrete values with such large deltas in the timestamp field. I am guessing he also needs processing of the field, to ignore the hour.
Alexander
Yea, you are probably right. I will leave the answer up since your info might be useful to someone.
Kevin Crowell
+5  A: 
SELECT DATE(timestamp), AVG(value)
FROM table
GROUP BY DATE(timestamp)

Since you want the day instead of each timestamp

webdestroya
+2  A: 
 select DATE(timestamp), AVG(value)
 from TABLE
 group by DATE(timestamp)
Michael Pakhantsov