I have a table, 'voting,' with 31 columns. For each of 28 REAL columns I
need to calculate averages both by groups and total. I tried:

sqlite> select AVG(pos) from voting where cat = 'eco';

and 0.0 was returned. Before this I tried combinations that were
syntactically incorrect; e.g.,

sqlite> select AVG(*) from voting where cat = 'eco' order by 'pos';
SQL error: wrong number of arguments to function AVG()
sqlite> select AVG() from voting where cat = 'eco' order by 'pos';
SQL error: wrong number of arguments to function AVG()

  The Definitive Guide does not have much on aggregate functions. I also
could not find any information on aggregates on the web site.

  What I need to do with the data from table 'voting' is (in Python using
psqlite2) is to calculate the average of each of 28 numeric columns for each
of the three 'pos' column values within each of the three 'cat' column
values. These will be saved to lists; for example, c1p1[...], c1p2[...],
c1p3[...] ... c3p3[...]. Then I can iterate through those lists and
calculate the averages of averages, i.e, c1, c2, c3.

  However, I'm stuck on the proper SQL syntax. A nudge in the right
direction -- including pointers to the appropriate documentation -- would be
much appreciated.

Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |          Accelerator(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to