473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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
Apr 20 '07 #1
2 11915
On Apr 20, 3:46 pm, "Dave" <d...@nospam.co.ukwrote:
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`

Apr 20 '07 #2
Feel a bit of a fool now, you always make it look so simple!

Many thanks, that's perfect

"strawberry" <za*******@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
On Apr 20, 3:46 pm, "Dave" <d...@nospam.co.ukwrote:
>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`

Apr 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ben | last post by:
I am trying to figure out the syntax for a query that will essentially give me the Percentage each of my areas contributes to the Whole. I know this can be achieved by multiple queries but I would...
5
by: James Conrad StJohn Foreman | last post by:
Have found http://www-128.ibm.com/developerworks/db2/library/techarticle/lyle/0110lyle.html which is quite helpful, but doesn't quite tell me what I want. I have a table, advertising_spend with...
4
by: Mahesh S | last post by:
Hi I am writing a sql query (added below) to calulate percentage. Its returning an integer value whereas I would like to get a float value (with 2 decimal precision). The query is: ...
0
by: mcyi2mr3 | last post by:
Hi all I'm interested in exploring the match query for a site in doing. can u return the relevance of a match query in percentage form? Also where are there good tutorials/resources on getting...
12
by: aldeb | last post by:
Below is the code I am using in a query that produces results that look like: Fault Category-------------No Fault Totals No Faults------------------------------77 Total Work...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
1
by: Monroeski | last post by:
I am using Access 2003. I am setting up a form where a user selects a Clinic or Ward, beginning date, and ending date, and the form outputs the averages of a few fields based on that criteria. I...
8
Nathan H
by: Nathan H | last post by:
I am trying to write a query that will result in showing records that have a large percentage difference among fields in a table. For instance: Table field1.Item field2.account1 (percentage)...
1
by: zufie | last post by:
I have used Sum(Abs()) to convert my neg. (-) values to pos. (+) values how can I obtain the correct percentage. For example, here is my expression from my query trying to calculate the correct...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.