Re: Tally up a field in a database...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 09 May 2003 17:39, Tristan.Pretty@risk.sungard.com wrote:
> I have a field in a DB that has either 0 or 1 as the value.
> It's part of a survey I'm doing.
>
> I want to be able to take that field and tally up all the results, giving
> a total for the user to see.
> I know it's simple, but the friday bug has gripped me...
>
> so if 30 users did the survey, and 12 selected 1, I want the result to
> show '12'

  select sum(field) from table;

OR

  select sum(field) as total from table;

For further info refer to your DBMS manual.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
You tread upon my patience.
		-- William Shakespeare, "Henry IV"
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux