I want to reorder a table and then group and average it's values. I
tried something similar to

SELECT AVG(a) FROM (SELECT a FROM table ORDER BY a) group by ROWID/10;

in order to take the average 'a' for groups of 10 succesive values. My
example fails. To understand I tried

SELECT ROWID FROM (SELECT * FROM table ORDER BY a);

and found that ROWID is null, not the record number as I expected. I
cannot modify my example adding ROWID to the nested select, as in 

SELECT AVG(a) FROM (SELECT ROWID, a FROM table ORDER BY a) group by ROWID/10;

as the ROWIDs would be in disorder.

Thus my question, what is the correct way of solving my problem?

Best regards,

Luis


-- 

                                                                  o
W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
Apdo. Postal 48-3, 62251             |                           (*)/\/  \
Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org                 


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to