percentage in sql query

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
dave [ Fr, 20 April 2007 16:46 ] [ ID #1693375 ]

Re: percentage in sql query

On Apr 20, 3:46 pm, "Dave" <d... [at] nospam.co.uk> 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`
zac.carey [ Fr, 20 April 2007 17:20 ] [ ID #1693376 ]

Re: percentage in sql query

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

Many thanks, that's perfect

"strawberry" <zac.carey [at] gmail.com> wrote in message
news:1177082424.673927.305730 [at] q75g2000hsh.googlegroups.com.. .
> On Apr 20, 3:46 pm, "Dave" <d... [at] nospam.co.uk> 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`
>
dave [ Fr, 20 April 2007 18:01 ] [ ID #1693377 ]
Datenbanken » mailing.database.mysql » percentage in sql query

Vorheriges Thema: Cannot access DB
Nächstes Thema: Alter combination of 2 existing columns as a unique key