"Terence" <[EMAIL PROTECTED]> wrote:
> 
> Is it possible to add the the running total of a column to the next row,
> something like this:
> 
> item,amount
> -----
> x,100
> y,200
> z,50
> 
> and get a result like this:
> 
> item,amount
> -----
> x,100
> y,300
> z,350

Take a look at user variables. You can do like

SELECT @a:=0;
SELECT item, @a:[EMAIL PROTECTED] FROM table_name;

Don't forget that rows are stored in unsorted order. So, MySQL will sum rows in that 
order as they are stored. 



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to