Return segmented average from SQL Query?
Posted
by Guillaume Filion
on Stack Overflow
See other posts from Stack Overflow
or by Guillaume Filion
Published on 2010-05-06T21:25:45Z
Indexed on
2010/05/06
21:28 UTC
Read the original article
Hit count: 183
Hi,
I measure the load on DNS servers every minute and store that into an SQL DB. I want to draw a chart of the load for the last 48 hours. That's 69120 (48*24*60) data points but my chart's only 800 pixels wide so to make things faster I would like my SQL query to return only ~800 data points.
It's seems to me like a pretty standard thing to do, but I've been searching the web and in books for such a thing for a while now and the closest I was able to find was a rolling average. What I'm looking for a more of a "segmented average": divide the 69120 data points in ~800 segments, then average each segment.
My SQL table is:
CREATE TABLE measurements (
ip int, measurement_time int, queries int, query_time float
)
My query looks like this
SELECT ip, queries FROM measurements WHERE measurement_time>(time()-172800)
Thanks a lot!
© Stack Overflow or respective owner