Hi Philip, what yoy called gand total is in @total for evevy row. you can just play :
> > set @total:=0; > > select name,price,quantity, price*quantity as > > subtotal,@total:[EMAIL PROTECTED] > > from fruits; select @total as "grand total"; that's all ! Mathias Selon Philip George <[EMAIL PROTECTED]>: > On May 29, 2005, at 2:34 PM, [EMAIL PROTECTED] wrote: > > > you can use mysql variables : > > > > set @total:=0; > > select name,price,quantity, price*quantity as > > subtotal,@total:[EMAIL PROTECTED] > > from fruits; > > > > > > +--------+-------+----------+---------- > > +-------------------------------+ > > | name | price | quantity | subtotal | > > @total:[EMAIL PROTECTED] | > > > > +--------+-------+----------+---------- > > +-------------------------------+ > > | orange | 1 | 2 | 2 | > > 2 | > > | banana | 1 | 4 | 4 | > > 6 | > > > > +--------+-------+----------+---------- > > +-------------------------------+ > > > > The total column will be incremented by subtotal in each row. > > > actually, i need a grand total of the entire ticket: > > 1 orange x 0.97 = 0.97 > + 3 pears x 1.09 = 3.27 > _________________________ > 4.24 < grand total > > > i think you're right that variables can be used to do this, but i can't > figure out how to get a grand total for the entire sale. > > but, i wouldn't scratch your head about it too much. i sort of gave up > on the idea in favor of doing the calculation in the client code at > runtime after selecting all the pertinent data. > > thanks though. :) > > - philip > > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]