473,748 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate Percentage

26 New Member
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 5544
MMcCarthy
14,534 Recognized Expert Moderator MVP
Can you post the full SQL of the query you are currently using.
Jul 3 '07 #2
ngweixiong
26 New Member
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 Recognized Expert Moderator MVP
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
ngweixiong
26 New Member
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 Recognized Expert Moderator MVP
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
ngweixiong
26 New Member
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
ngweixiong
26 New Member
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
18534
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 = 40% But I wanted to do the reverse of that....to calculate the SellPrice, where only Cost and the desired GPP are supplied. I was struggling with my high-school math, and having a heck of a time with
4
61779
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 to round the result?
1
5126
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
3889
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 image. Here is the class method, it obviously doesn't work: /**
39
3321
by: Umesh | last post by:
Plese help. Is there any software by which we can do that?
3
9980
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 report. Can some one please help me about this issue ?
3
8671
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 u, tbl_user_company c where s.selection_type = 'INDUSTRY' and u.User_Company_ID = c.Company_ID
4
5972
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, QuestionA, QuestionB, QuestionC, etc. Each of these is populated from a form (Form1) which uses combo boxes with values of YES, NO and NA. He has created a report which displays the answers to the questions for each record, but wants to calculate...
17
2207
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 few instances where it varies depending on a GrantNo and ProjectNo. To convert APAmount to NetAmount, I will need to incorporate these criteria. If I have 2 invoices for the APAmount $100 and $200 and these belong to two projects with two...
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.