Re: Adding totals
| From: | Frank Flynn | Date: | Tue, 21 May 2002 16:33:39 +0000 |
| Subject: | Re: Adding totals | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-19327@lists.php.net to get a copy of this message | ||
I'm sure you could add up the results as you fetch them and only display the
total. But even easier why not ask the DB to return the sum?
SELECT sum(my_col)
FROM my_table
WHERE <whatever>
This will only return one row with the total (note you can only select
columns that are using an aggregate for this to work) See also "GROUP BY"
Good luck,
Frank
>
> From: César L. Aracena <caracena@infovia.com.ar>
> Date: Tue, 21 May 2002 01:49:28 -0300
> To: "PHP DB List" <php-db@lists.php.net>
> Subject: Adding totals
>
> Hi all,
>
> Is there a way for me in PHP4 to add all the contens (floating numbers) of a
> cartain column whithin a row and show up the result? I have several time
> inputs and need to show the total.
>
> Thanx.
>
> Cesar Aracena
> caracena@infovia.com.ar
> Neuquen, Argentina
--
Frank Flynn
Poet, Artist & Mystic