percentage in sql query

percentage in sql query

am 20.04.2007 16:46:13 von dave

I have a table of score which are 1's and 0's.

How would I go about writing a query to get the percentage of 1's against
the toal number of records?

Many thanks

Re: percentage in sql query

am 20.04.2007 17:20:24 von zac.carey

On Apr 20, 3:46 pm, "Dave" wrote:
> I have a table of score which are 1's and 0's.
>
> How would I go about writing a query to get the percentage of 1's against
> the toal number of records?
>
> Many thanks

SELECT (SUM( score ) / COUNT( score )) *100 percentage FROM `scores`

Re: percentage in sql query

am 20.04.2007 18:01:36 von dave

Feel a bit of a fool now, you always make it look so simple!

Many thanks, that's perfect

"strawberry" wrote in message
news:1177082424.673927.305730@q75g2000hsh.googlegroups.com.. .
> On Apr 20, 3:46 pm, "Dave" wrote:
>> I have a table of score which are 1's and 0's.
>>
>> How would I go about writing a query to get the percentage of 1's against
>> the toal number of records?
>>
>> Many thanks
>
> SELECT (SUM( score ) / COUNT( score )) *100 percentage FROM `scores`
>