|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: How to SUM every row for SubTotal?
From: Afivi Andri S (afivi_as
binasanprima.com)
Date: Wed Nov 23 2005 - 02:15:44 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
but it can't work if multiple tables.
how it can use for multiple tables?
----- Original Message -----
From: "ISC Edwin Cruz" <ecruz
medel.com.mx>
To: "'The Nice Spider'" <thenicespider
yahoo.com>; <mysql
lists.mysql.com>
Sent: Wednesday, November 23, 2005 7:13 AM
Subject: RE: How to SUM every row for SubTotal?
> 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:=
a+qty 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:thenicespider
yahoo.com]
> 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/mysql?unsub=afivi_as
binasanprima.com
>
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]