Hi, > how can I generate a list of deltas between columns in different rows for > the entire table? > what I need is an sql command that does something like this: > for N =0 to i do : select "colA of current rowN" - "colA of pervious > row(N-1)" from tab1; > > ColA = floating point number.
You can do something like: select select @v:=0; select colA-@v,@v:=colA from tab1; Example: mysql> select * from ajuda; +----+----+ | id | a | +----+----+ | 1 | 3 | | 2 | 4 | | 3 | 5 | | 4 | 7 | | 5 | 10 | +----+----+ 5 rows in set (0.00 sec) mysql> select @v:=0; +-------+ | @v:=0 | +-------+ | 0 | +-------+ 1 row in set (0.01 sec) mysql> select a-@v,@v:=a from ajuda; +------+-------+ | a-@v | @v:=a | +------+-------+ | 3 | 3 | | 1 | 4 | | 1 | 5 | | 2 | 7 | | 3 | 10 | +------+-------+ 5 rows in set (0.00 sec) mysql> -- dsoares (sql) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php