On 1 Dec 2009, at 7:29pm, npearson99 wrote:

> Example Table:
> tableID
> Minute
> Watt
> 
> I'm trying to sum average the watt column by minute.

Use 'avg(X)' on the result of a SELECT which finds all the samples within a 
particular minute.

http://www.sqlite.org/lang_aggfunc.html

It is unfortunate that the SQLite documentation includes no examples, and 
Google turns out just examples where people are defining their own aggregate 
functions.  However, I understand that aggregate functions can be used as 
follows:

SELECT avg(watt) FROM samples WHERE minute = 10

You may even be able to make SQLite obtain all the values you want in one 
statement:

SELECT minute,avg(watt) FROM samples GROUP BY minute

but that depends on how your want your own software to work and how you want to 
handle situations where there are zero samples in a particular minute.

Simon.

PS: Your questions was very clearly phrased.  That's the way to get eager 
answers.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to