> Thanks Rich, don't think I explained myself very well though. What I'm
> trying to do is:
>
> SELECT myValue, COUNT(myValue) AS Whatever
> FROM myTable
> Where myValue=1 (and then on up to 5)
>
> Then output the count as a percentage of the whole recordcount.
>
> I realise I could loop it from 1 to 5 but myValue is already being looped
> and I'm going to end up with a silly amount of queries generated
>

Just use Rich's query to get the count for all of the values, so you'll get

myValue    Whatever
1                10
2                15
3                5
4                8
5                25

a simple loop will get you the total number of responses.

TotalPoll = 0;
for (i=1; i lte myQuery.RecordCount; i=i+1) TotalPoll =
TotalPoll+myQuery.Whatever[i];

Now you can get your percentages, output all your responses with one query.

Stephen



-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to