Click here to Skip to main content
15,886,052 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table called info with 3 fields namely;
Name   totalvisits   specialvisits
mmm    30            15
kkk    49            49
jjj    60            30
mu     40            -99
jh     -99           -99


-99 denotes missing values, I want to calculate percentage of specialvisits to totalvisits. here is what my expression in ms access;

percentage special visit:[info].[specialvisits]/[info].[totalvisits]*100

It is giving me the correct answers for all values where there no missing data.how will my expression be like so that it disregard the missing values.
Posted
Updated 12-Aug-12 23:54pm
v2

1 solution

Use WHERE statement in your query:
SQL
SELECT [Name], [totalvisits], [specialvisits],  [totalvisits]/[specialvisits] * 100 AS Percentage
FROM info
WHERE  ([totalvisits]>0) AND ([specialvisits]>0);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900