Below is the code I am using in a query that produces results that look like: Fault Category------------- No Fault Totals
No Faults------------------------------77
Total Work Units-------------------521
I would like to also show in the query the percentage of No Faults. In this instance I would need to divide
the 77 no faults by the 521 total work units. Is there a way to do this and show the answer in the query.
I do not want this in a report, just the query. -
SELECT FaultCategory, COUNT(*) As [No Fault Totals]
-
FROM WorkUnitsFaultsMainTBL
-
WHERE BuildID IN ("E010","C809","F001","C810","F187","A910","M173","M174") AND
-
FaultCategory IN ('No Faults') AND
-
[TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt]
-
AND
-
[Forms]![Queries_ReportsFRM]![EndDateTxt]
-
GROUP BY FaultCategory
-
-
UNION ALL SELECT 'Total Work Units' As FaultCategory, COUNT([WorkUnit]) As [WU Totals]
-
FROM (Select Distinct [WorkUnit]
-
FROM WorkUnitsFaultsMainTBL
-
WHERE BuildID IN ("E010","C809","F001","C810","F187","A910","M173","M174") AND
-
[TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt]
-
AND
-
[Forms]![Queries_ReportsFRM]![EndDateTxt]) As vTbl;
12 8618
As Pink Floyd said Is anybody out there?
Below is the code I am using in a query that produces results that look like: Fault Category-------------No Fault Totals
No Faults------------------------------77
Total Work Units-------------------521
I would like to also show in the query the percentage of No Faults. In this instance I would need to divide
the 77 no faults by the 521 total work units. Is there a way to do this and show the answer in the query.
I do not want this in a report, just the query. -
SELECT FaultCategory, COUNT(*) As [No Fault Totals]
-
FROM WorkUnitsFaultsMainTBL
-
WHERE BuildID IN ("E010","C809","F001","C810","F187","A910","M173","M174") AND
-
FaultCategory IN ('No Faults') AND
-
[TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt]
-
AND
-
[Forms]![Queries_ReportsFRM]![EndDateTxt]
-
GROUP BY FaultCategory
-
-
UNION ALL SELECT 'Total Work Units' As FaultCategory, COUNT([WorkUnit]) As [WU Totals]
-
FROM (Select Distinct [WorkUnit]
-
FROM WorkUnitsFaultsMainTBL
-
WHERE BuildID IN ("E010","C809","F001","C810","F187","A910","M173","M174") AND
-
[TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt]
-
AND
-
[Forms]![Queries_ReportsFRM]![EndDateTxt]) As vTbl;
This should point you in the right direction: - The Percentage No Faults couold be obtained by: Format$([No Faults]/[Total Work Units],"Percent")
Thank you,
Where do I insert that in my SQL Code?
NeoPa 32,534
Expert Mod 16PB
As Pink Floyd said Is anybody out there?
Is there anybody out there?
However, I'm not sure of the appropriateness in this case. This is a forum supported by members who donate their time, not a paid-for support service with a four-hour SLA.
If you need to bump a thread then feel free to after a day (at least) of inactivity.
MODERATOR.
NeoPa 32,534
Expert Mod 16PB
In this case, unless both values are available in the same record of a query this cannot be done.
There are tricks for arranging data to be merged into a single record but generally they depend on the data you're dealing with. I'm afraid your explanation doesn't give enough information about the nature of your data to enable one even to start thinking of a suitable trick.
In general though, you would need to identify the data from individual input records (flag the values you're interested in somehow), group them, then pick out the identified inner values somehow to perform the arithmetic on.
NeoPa,
Thank you for your information. As far as the inappropriate post please lighten up! I was trying to be friendly and show some humor!! I am sorry if you were offended!! As far as not providing enough info, I beg to differ. I have received several answers from other forums with the same posting. Maybe I did not provide enough info for you. If that is the case again I am sorry.
This is the best solution so far:
Why not split your original post into two queries?
Q1:
CODE
SELECT COUNT(*) As [No Fault Totals]
FROM WorkUnitsFaultsMainTBL
WHERE BuildID IN ("E010","C809","F001","C810","F187","A910","M173", "M174") AND
FaultCategory IN ('No Faults') AND
[TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt]
AND
[Forms]![Queries_ReportsFRM]![EndDateTxt]
GROUP BY FaultCategory
and Q2:
CODE
SELECT COUNT([WorkUnit]) As [WU Totals]
FROM (Select Distinct [WorkUnit]
FROM WorkUnitsFaultsMainTBL
WHERE BuildID IN ("E010","C809","F001","C810","F187","A910","M173", "M174") AND
[TodaysDate] BETWEEN [Forms]![Queries_ReportsFRM]![StartDateTxt]
AND
[Forms]![Queries_ReportsFRM]![EndDateTxt]) As vTbl;
Then a query that links them. Q3:
CODE
SELECT [q1].[No Fault Totals]/[q2].[WU Totals] AS ratio
FROM q1, q2;
I leave the error checking / divide by zero checks to you.
Shalom
NeoPa 32,534
Expert Mod 16PB
I'm sorry you failed to notice the humour in my response.
However, as a moderator I have to (and want to) enforce the rules and guidelines of the site and make members aware of them if they stray across them inadvertantly or otherwise.
In the view of the moderators of the site, this is the best way of reassuring our members (and especially our experts) that they can expect to be treated with respect when visiting or working (donating their free time) here.
I'm sorry if that's not an environment you're comfortable with.
MODERATOR.
Geez NeoPa, you seem to be pretty uptight as a moderator. I did not disrepect anyone with anything I said in my posts. Who said anything about being uncomfortable with the environment of this forum?. I hope you are not one of those moderators who judges everyone and gets on his/her high horse thinking he/she knows how others feel about things! I apologized in my last post if my earlier post was out of line! I also posted a solution that was provided for my issue from another forum. The lecture is not needed. Thanks for all help!
NeoPa 32,534
Expert Mod 16PB
Wow, you're a real joy to have around aren't you.
Hey, I guess whining isn't a crime.
Peace.
Geez NeoPa, you seem to be pretty uptight as a moderator. I did not disrepect anyone with anything I said in my posts. Who said anything about being uncomfortable with the environment of this forum?. I hope you are not one of those moderators who judges everyone and gets on his/her high horse thinking he/she knows how others feel about things! I apologized in my last post if my earlier post was out of line! I also posted a solution that was provided for my issue from another forum. The lecture is not needed. Thanks for all help!
aldeb
NeoPa was simply trying to guide you in the quickest way to get a solution in this forum. Although you said you received answers from other forums you obviously didn't get a solution. Following his advice and posting some extra details would give the experts more to work with and therefore you would be more likely to find an appropriate solution.
Nobody is trying to be uptight but simply spending their spare time trying to help you find a solution to your problem. One of the few thinks we do insist on in this forum is respect for the experts as they donate their valuable free time. NeoPa was simply trying to advise you that if you wish to attract the attention of experts of which we have some excellent ones then a different approach may be more successful.
ADMIN
As Pink Floyd said Is anybody out there?
Typical, I think the track record of the Access forum speaks for itself. Pay no attention MS Access Experts you're doing a great job!
Aric
Wow, you're a real joy to have around aren't you.
Hey, I guess whining isn't a crime.
Now this I would say is an inappropriate post and disrespectful also!
Typical, I think the track record of the Access forum speaks for itself. Pay no attention MS Access Experts you're doing a great job!
Way to jump in there Aric with your solution to the problem. I am glad you volunteer
your time to help with his forum! Providing answers to the actual posted problem
might be a little more beneficial than jumping in with your two cents to something
that you should not be involved in!
If these are the typical responses to issues on this forum you may remove me if it makes
you all feel better!
Shalom
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben |
last post by:
I am trying to figure out the syntax for a query that will essentially
give me the Percentage each of my areas contributes to the Whole. I
know this can be achieved by multiple queries but I would...
|
by: James Conrad StJohn Foreman |
last post by:
Have found
http://www-128.ibm.com/developerworks/db2/library/techarticle/lyle/0110lyle.html
which is quite helpful, but doesn't quite tell me what I want.
I have a table, advertising_spend with...
|
by: Mahesh S |
last post by:
Hi
I am writing a sql query (added below) to calulate percentage. Its
returning an integer value whereas I would like to get a float value
(with 2 decimal precision).
The query is:
...
|
by: mcyi2mr3 |
last post by:
Hi all
I'm interested in exploring the match query for a site in doing.
can u return the relevance of a match query in percentage form? Also
where are there good tutorials/resources on getting...
|
by: Dave |
last post by:
I have a table of score which are 1's and 0's.
How would I go about writing a query to get the percentage of 1's against
the toal number of records?
Many thanks
|
by: ngweixiong |
last post by:
Hi,
i want to create a Ms Access query such that it will auto calculate its percentage out.
For example,
i have Field: (lead time between order date and invoice date). i want to calculate...
|
by: Micheal |
last post by:
Greetings Access Group,
Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
|
by: Monroeski |
last post by:
I am using Access 2003. I am setting up a form where a user selects a Clinic or Ward, beginning date, and ending date, and the form outputs the averages of a few fields based on that criteria. I...
|
by: zufie |
last post by:
I have used Sum(Abs()) to convert my neg. (-) values to pos.
(+) values how can I obtain the correct percentage.
For example, here is my expression from my query trying to calculate
the correct...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |