SearchSearch   

percentage in sql query

 
   Webmaster Forums (Home) -> MySQL RSS
Next:  Alter combination of 2 existing columns as a uniq..  
Author Message
Dave

External


Since: Jul 13, 2006
Posts: 29



(Msg. 1) Posted: Fri Apr 20, 2007 2:46 pm
Post subject: percentage in sql query
Archived from groups: mailing>database>mysql (more info?)

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
Back to top
strawberry

External


Since: Apr 20, 2007
Posts: 21



(Msg. 2) Posted: Fri Apr 20, 2007 2:46 pm
Post subject: Re: percentage in sql query
Archived from groups: per prev. post (more info?)

On Apr 20, 3:46 pm, "Dave" <d... RemoveThis @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`
Back to top
Dave

External


Since: Jul 13, 2006
Posts: 29



(Msg. 3) Posted: Fri Apr 20, 2007 4:01 pm
Post subject: Re: percentage in sql query
Archived from groups: per prev. post (more info?)

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

Many thanks, that's perfect

"strawberry" <zac.carey RemoveThis @gmail.com> wrote in message
news:1177082424.673927.305730@q75g2000hsh.googlegroups.com...
> On Apr 20, 3:46 pm, "Dave" <d... RemoveThis @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`
>
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> MySQL
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum