mysql> select * from table5; +--------+------+ | code | qty | +--------+------+ | 100 | 30 | | 200 | 20 | | 300 | 25 | +--------+------+ 3 rows in set (0.00 sec)
mysql> set @a=0; Query OK, 0 rows affected (0.05 sec) mysql> select code,qty,@a:[EMAIL PROTECTED] as subtotal from table5; +--------+------+------------+ | code | qty | subtotal | +--------+------+------------+ | 100 | 30 | 30 | | 200 | 20 | 50 | | 300 | 25 | 75 | +--------+------+------------+ 3 rows in set (0.00 sec) mysql> I hope that it helps you Regards! -----Mensaje original----- De: The Nice Spider [mailto:[EMAIL PROTECTED] Enviado el: Martes, 22 de Noviembre de 2005 05:27 p.m. Para: mysql@lists.mysql.com Asunto: How to SUM every row for SubTotal? If I have table like: CODE QTY 100 30 200 20 300 25 and I want a result like: CODE QTY SUBTOTAL 100 30 30 200 20 50 (this come from 30+20) 300 25 75 (this come from 50+25) How to write query like that? --------------------------------- Yahoo! FareChase - Search multiple travel sites in one click. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]