Skip to main content
Inspiring
December 13, 2006
Question

Help "count" records

  • December 13, 2006
  • 4 replies
  • 339 views
I want to count all records in a recordset based on the value and then
determine the % of records that have that value. Any pointers on how to do
this would be appreciated. -Thanks


This topic has been closed for replies.

4 replies

Inspiring
December 13, 2006
Got it, that worked great, thanks for the response! -Ken

"David Powers" <david@example.com> wrote in message
news:elpmf8$mhu$1@forums.macromedia.com...
> KP wrote:
>> Is each query in it's own recordset or both in one?
>
> Separate.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Inspiring
December 13, 2006
KP wrote:
> Is each query in it's own recordset or both in one?

Separate.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
December 13, 2006
David, how do you count if you have a lets say a mysql table that has a poll such as...

pollID | pollNo | pollName
1 | 1 | Mark
2 | 1 | Mark
3 | 2 | David
4 | 2 | David
5 | 1 | Mark

Now lets say I wish to count in the pollNo of all the 1's and all the 2's.
So lets say I have on my php page I have somethig that says

Mark has 3 votes
David has 2 votes

How is this accomplished.

Thank you,
AdonaiEchad
Inspiring
December 13, 2006
Is each query in it's own recordset or both in one?


"David Powers" <david@example.com> wrote in message
news:elpiob$idh$1@forums.macromedia.com...
> KP wrote:
>> I want to count all records in a recordset based on the value and then
>> determine the % of records that have that value. Any pointers on how to
>> do this would be appreciated. -Thanks
>
> Create two SQL queries.
>
> SELECT COUNT(columnName) FROM myTable
>
> SELECT COUNT(columName) FROM myTable
> WHERE columnName = variableValue
>
> Divide the result of the second query by the result of the first and
> multiply by 100.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Inspiring
December 13, 2006
KP wrote:
> I want to count all records in a recordset based on the value and then
> determine the % of records that have that value. Any pointers on how to do
> this would be appreciated. -Thanks

Create two SQL queries.

SELECT COUNT(columnName) FROM myTable

SELECT COUNT(columName) FROM myTable
WHERE columnName = variableValue

Divide the result of the second query by the result of the first and
multiply by 100.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/