473,394 Members | 1,740 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,394 software developers and data experts.

Calculate Percentage

Hi,

I have a Ms Access query which i used to calculate how many times the leadtime is
a) less than 7 days
b) 7-14 days
c) more than 14 days

With the query results, i will like to convert my results to percentage.
E.G.
how many percent is less than 7 days, 7-14 days and more than 14 days.

Thanks.
Jun 28 '07 #1
7 5510
MMcCarthy
14,534 Expert Mod 8TB
Can you post the full SQL of the query you are currently using.
Jul 3 '07 #2
Can you post the full SQL of the query you are currently using.
Hi,

below are my codes.

Thanks alot!!

Expand|Select|Wrap|Line Numbers
  1. SELECT [lead Time between PO date and Invoice date].[PO date], [lead Time between PO date and Invoice date].PO, Avg([lead Time between PO date and Invoice date].[TL PO and Inv]) AS [AvgOfTL PO and Inv]
  2. FROM [lead Time between PO date and Invoice date]
  3. GROUP BY [lead Time between PO date and Invoice date].[PO date], [lead Time between PO date and Invoice date].PO;
Jul 4 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Try something like this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT "Less than 7 days" As Period, DCount("[TL PO and Inv]","lead Time between PO date and Invoice date") AS TotalCount, Count([TL PO and Inv]) As CountTL, CountTL/TotalCount As PercentTL
  2. FROM [lead Time between PO date and Invoice date]
  3. WHERE [PO date] BETWEEN Date() AND Date()-7
  4. UNION
  5. SELECT "7 - 14 days" As Period, DCount("[TL PO and Inv]","lead Time between PO date and Invoice date") AS TotalCount, Count([TL PO and Inv]) As CountTL, CountTL/TotalCount As PercentTL
  6. FROM [lead Time between PO date and Invoice date]
  7. WHERE [PO date] BETWEEN Date()-7 AND Date()-14
  8. UNION
  9. SELECT "Greater than 14 days" As Period, DCount("[TL PO and Inv]","lead Time between PO date and Invoice date") AS TotalCount, Count([TL PO and Inv]) As CountTL, CountTL/TotalCount As PercentTL
  10. FROM [lead Time between PO date and Invoice date]
  11. WHERE [PO date] < Date()-14;
  12.  
Jul 4 '07 #4
Try something like this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT "Less than 7 days" As Period, DCount("[TL PO and Inv]","lead Time between PO date and Invoice date") AS TotalCount, Count([TL PO and Inv]) As CountTL, CountTL/TotalCount As PercentTL
  2. FROM [lead Time between PO date and Invoice date]
  3. WHERE [PO date] BETWEEN Date() AND Date()-7
  4. UNION
  5. SELECT "7 - 14 days" As Period, DCount("[TL PO and Inv]","lead Time between PO date and Invoice date") AS TotalCount, Count([TL PO and Inv]) As CountTL, CountTL/TotalCount As PercentTL
  6. FROM [lead Time between PO date and Invoice date]
  7. WHERE [PO date] BETWEEN Date()-7 AND Date()-14
  8. UNION
  9. SELECT "Greater than 14 days" As Period, DCount("[TL PO and Inv]","lead Time between PO date and Invoice date") AS TotalCount, Count([TL PO and Inv]) As CountTL, CountTL/TotalCount As PercentTL
  10. FROM [lead Time between PO date and Invoice date]
  11. WHERE [PO date] < Date()-14;
  12.  

Hi,

Can kindly explain the code? thanks alot
Jul 5 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
This is a union query. Essentially it is three queries which gets the records based on different criteria but returns them as one set of records.

The first column returned is just a string to describe the record being returned. The second is just a way of retrieving the total count of records for use in calculating percentage. The third column is the count of records in this criteria and the fourth calculates the percentage. Then the where statement on each SELECT statement sets the criteria e.g. In the last 7 days would be the first one.
Jul 5 '07 #6
This is a union query. Essentially it is three queries which gets the records based on different criteria but returns them as one set of records.

The first column returned is just a string to describe the record being returned. The second is just a way of retrieving the total count of records for use in calculating percentage. The third column is the count of records in this criteria and the fourth calculates the percentage. Then the where statement on each SELECT statement sets the criteria e.g. In the last 7 days would be the first one.

Hi,

thanks for the code.

I have modify the code and it still does not calaculate the percentage.

my query (Average time lead between PO date and Inv Date) only have the following fields,
PO date
PO
AvgOfTL PO and Inv


Expand|Select|Wrap|Line Numbers
  1. SELECT "Less than 7 days" AS Period, DCount("[PO]","Average time lead between PO date and Inv Date") AS TotalCount, Count([AvgOfTL PO and Inv]) AS CountTL, CountTL/TotalCount AS PercentTL
  2. FROM [Average time lead between PO date and Inv Date]
  3. WHERE [PO date] BETWEEN Date() AND Date()-7
  4. UNION
  5. SELECT "7 - 14 days" AS Period, DCount("[PO]","Average time lead between PO date and Inv Date") AS TotalCount, Count([PO]) AS CountTL, CountTL/TotalCount AS PercentTL
  6. FROM [Average time lead between PO date and Inv Date]
  7. WHERE [PO date] BETWEEN Date()-7 AND Date()-14
  8. UNION
  9. SELECT "Greater than 14 days" AS Period, DCount("[PO]","Average time lead between PO date and Inv Date") AS TotalCount, Count([PO]) AS CountTL, CountTL/TotalCount AS PercentTL
  10. FROM [Average time lead between PO date and Inv Date]
  11. WHERE [PO date] < Date()-14;
please help
Jul 10 '07 #7
any one can help???

thanks alot...
Jul 16 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Don Leverton | last post by:
Hi Folks, I *can* calculate the Gross Profit Percentage where both the Cost and SellPrice are known, using the formula: (SellPrice - Cost) / SellPrice = GPP eg ($24.92 - $14.95) / $24.92 =...
4
by: Bill | last post by:
I have two long values that are passed in an event. I would like to calculate percent complete as an int but am not quite sure how. Do I need to convert them to doubles and then use the Math class...
1
by: toluj | last post by:
Hi, pls could anyone help me with the script to calculate the percentage btwn two fields in a table.
1
by: comp.lang.php | last post by:
Sorry folks, I'm on a roll!!! I need to calculate the height or width of an image if you change either the width or height and don't change BOTH of them at the same time, this is to "vector" the...
39
by: Umesh | last post by:
Plese help. Is there any software by which we can do that?
3
by: tulikapuri | last post by:
Dear Friends, I am using the method to cal. percentage in report but no sucess it gives #Num! instead of a number. I am following the steps as given in help to calculate percentage value on a...
3
by: smileyangeluv | last post by:
Hi, Would like to get percentage for generated column. Any idea on how to do that?? Following SQL statement SELECT s.Selection_Desc, count(u.user_id) from tbl_system_selection s, tbl_user...
4
ollyb303
by: ollyb303 | last post by:
Hello, Trying to help a friend/colleague out with a database and we've both drawn a blank. Not even sure if this is possible. The database has a table (Table1) with a several columns: ID,...
17
by: MNNovice | last post by:
Calculate net amount based on conditions ________________________________________ I need to calculate a net amount that is based on FedRatio. Normally the FedRatio is set to be 80% but there are a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.