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 5510
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;
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
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 =...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |