Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating percentages in Access 2003 2

Status
Not open for further replies.

commonskills

Programmer
Joined
Jan 28, 2008
Messages
7
Location
US
Thank you,

I have a table that looks something like this:

Students Taken Test
1 20071201
2 20071201
3 20071205
4 20071205
5 20071205
6 20080108
7 blank
8 blank

This is multipled by 100 students though. My question is how do I create a query or field where it will calculate the percentage of student who have taken the test where the above example would read .75% and I am trying to do this in ACCESS 2003? Thank you again for your time.
 
SELECT Count([Take Test])/Count(*) AS [%]
FROM yourTable

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



[tt]
SELECT SUM(iif([Taken Test] is not null,1,0))/count(*)
FROM ...
[/tt]
Why do you have your dates as TEXT strings?

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Skip, the COUNT aggregate function doesn't count the null values unless you used *, so no need of the IIf function.
 
Thank you for your time,

I'm doing the Count([Take Test])/Count(*) AS [%] expresion in design view of a query, under the Criteria tab, in expression builder, is that correct?

I made the database in about two days but Ive been working on the percentages for about a week now. I have a networking/ cisco router background. You guys are super human!!!
 
The suggestions by both Skip and PH are what you might view in the SQL view of the query.

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
does this look right:

select Count([CLASSES DATABASE].TOTAL)/Count(*) AS [%] [COUNTOFTESTTAKEN]
FROM [MASTER CLASS DATABASE];

Thank you
 
Doesn't look correct. What's wrong with the syntax suggested by PH?
Code:
SELECT Count([Taken Test])/Count(*) AS [PctTaken] 
FROM [Your unkown table name];
If you can't figure this out, come back with your actual table and field names.

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
SELECT DISTINCTROW Count([HQ CO TRNG DATABASE].[EQUAL OPPORTUNITY]) AS [CountOfEQUAL OPPORTUNITY], Count([HQ CO TRNG DATABASE].TOTAL) AS CountOfTOTAL
FROM [HQ CO TRNG DATABASE];



Thanks Duane MS Access MVP, PHV, and Skip!!!!!!!!!!!!!
 
CountOfEQUAL OPPORTUNITY CountOfTOTAL
35 211

This is what the fields look like, im not certain if this is helpful in solving this but it 35 have take the class out off a possible 211 people
 
If you want the percent, you must look back at every SQL syntax provided to see the division "/".

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
SELECT DISTINCTROW Count([EQUAL OPPORTUNITY])/ Count(TOTAL) AS [%] FROM [HQ CO TRNG DATABASE];


got it Thanks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top