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.
7 5544 MMcCarthy 14,534
Recognized Expert Moderator MVP
Can you post the full SQL of the query you are currently using.
Can you post the full SQL of the query you are currently using.
Hi,
below are my codes.
Thanks alot!! - 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]
-
FROM [lead Time between PO date and Invoice date]
-
GROUP BY [lead Time between PO date and Invoice date].[PO date], [lead Time between PO date and Invoice date].PO;
MMcCarthy 14,534
Recognized Expert Moderator MVP
Try something like this ... -
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
-
FROM [lead Time between PO date and Invoice date]
-
WHERE [PO date] BETWEEN Date() AND Date()-7
-
UNION
-
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
-
FROM [lead Time between PO date and Invoice date]
-
WHERE [PO date] BETWEEN Date()-7 AND Date()-14
-
UNION
-
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
-
FROM [lead Time between PO date and Invoice date]
-
WHERE [PO date] < Date()-14;
-
Try something like this ... -
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
-
FROM [lead Time between PO date and Invoice date]
-
WHERE [PO date] BETWEEN Date() AND Date()-7
-
UNION
-
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
-
FROM [lead Time between PO date and Invoice date]
-
WHERE [PO date] BETWEEN Date()-7 AND Date()-14
-
UNION
-
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
-
FROM [lead Time between PO date and Invoice date]
-
WHERE [PO date] < Date()-14;
-
Hi,
Can kindly explain the code? thanks alot
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.
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 - 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
-
FROM [Average time lead between PO date and Inv Date]
-
WHERE [PO date] BETWEEN Date() AND Date()-7
-
UNION
-
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
-
FROM [Average time lead between PO date and Inv Date]
-
WHERE [PO date] BETWEEN Date()-7 AND Date()-14
-
UNION
-
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
-
FROM [Average time lead between PO date and Inv Date]
-
WHERE [PO date] < Date()-14;
please help
any one can help???
thanks alot...
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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?
|
by: toluj |
last post by:
Hi,
pls could anyone help me with the script to calculate the percentage btwn two fields in a table.
|
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:
/**
|
by: Umesh |
last post by:
Plese help. Is there any software by which we can do that?
| |
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 ?
|
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
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |