Without looking at your select statement it's very hard to help. But general suggestion is insert your results into temporary table and then issue a select on that table joined with itself with condition like t.rowid = prev.rowid + 1.
Pavel On Wed, Aug 19, 2009 at 10:10 AM, Mário Anselmo Scandelari Bussmann<mario.bussm...@gmail.com> wrote: > I have a table like this: > > petr4 > ----------- > rowid|data|preabe|premax|premin|preult|voltot > 1|2007-01-02|50.0|50.45|49.76|50.45|256115409.0 > 2|2007-01-03|50.16|50.4|48.01|48.7|492591256.0 > 3|2007-01-04|48.5|48.75|47.4|47.65|505916186.0 > 4|2007-01-05|47.2|47.99|45.1|46.19|581485748.0 > 5|2007-01-08|46.5|47.14|45.8|46.59|452501627.0 > 6|2007-01-09|45.97|46.39|44.61|45.52|587958198.0 > 7|2007-01-10|44.51|45.26|44.3|45.25|470899428.0 > 8|2007-01-11|44.9|46.43|44.76|45.21|542684895.0 > 9|2007-01-12|45.3|45.61|44.8|45.15|478912234.0 > 10|2007-01-15|45.61|45.85|44.89|44.89|317073087.0 > > I need a select that returns data,preult,previous data and previous preult: > > 2007-01-03|48.7|2007-01-02|50.45 > 2007-01-04|47.65|2007-01-03|48.7 > 2007-01-05|46.19|2007-01-04|47.65 > 2007-01-08|46.59|2007-01-05|46.19 > 2007-01-09|45.52|2007-01-08|46.59 > 2007-01-10|45.25|2007-01-09|45.52 > 2007-01-11|45.21|2007-01-10|45.25 > 2007-01-12|45.15|2007-01-11|45.21 > 2007-01-15|44.89|2007-01-12|45.15 > > How can I do that using only sql (no python, c or perl, no cursor)? > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users