i have two queries I want to join so i can get the percentages from each department of completed work orders but not sure how to go about it. I know i want a join and a crosstab query so i can display the results in a report.
The first query calculates the numerator, - SELECT Count(MaximoReport.WorkOrder) AS CountOfWorkOrder,
-
MaximoReport.[Assigned Owner Group]
-
FROM MaximoReport
-
WHERE (((MaximoReport.WorkType) In ("PMINS","PMOR","PMPDM","PMREG","PMRT"))
-
AND ((MaximoReport.Status) Like "*COMP")
-
AND ((MaximoReport.[Target Start])>=DateAdd("h",-1,[Enter the start date])
-
And (MaximoReport.[Target Start])<DateAdd("h",23,[Enter the end date]))
-
AND ((MaximoReport.ActualLaborHours)<>"00:00")
-
AND ((MaximoReport.ActualStartDate)>=DateAdd("h",-11.8,[Enter the start date])
-
And (MaximoReport.ActualStartDate)<DateAdd("h",23,[Enter the end date])))
-
GROUP BY MaximoReport.[Assigned Owner Group];
while the second query calculates the denominator: - SELECT Count(MaximoReport.WorkOrder) AS CountOfWorkOrder,
-
MaximoReport.[Assigned Owner Group]
-
FROM MaximoReport
-
WHERE (((MaximoReport.WorkType) In ("PMINS","PMOR","PMPDM","PMREG","PMRT"))
-
AND ((MaximoReport.Status)<>"CAN")
-
AND ((MaximoReport.[Target Start])>=DateAdd("h",-11.8,[Enter the start date])
-
And (MaximoReport.[Target Start])<DateAdd("h",23,[Enter the end date])))
-
GROUP BY MaximoReport.[Assigned Owner Group];
please advise how i cann join the two queries to get the percentages of the departments and then do a crosstab query.
If there a better way of doing this please also let me know.
Thought of running the query this way but I get errors. - SELECT SUM(iif((MaximoReport.Status Like "*COMP"),iif((MaximoReport.ActualLaborHours<>"00:00"),1,0),0)) AS CountCompleted,
-
SUM(iif((MaximoReport.Status) <> "CAN",1,0)) AS CountTotal,
-
Round([CountCompleted]/[CountTotal]*100,1) AS PercentCompleted,
-
MaximoReport.[Assigned Owner Group]
-
FROM MaximoReport
-
WHERE (((MaximoReport.WorkType) In ("PMINS","PMOR","PMPDM","PMREG","PMRT"))
-
AND ((MaximoReport.[Target Start])>=DateAdd("h",-1,[Enter the start date])
-
AND (MaximoReport.[Target Start])<DateAdd("h",23,[Enter the end date]))
-
AND ((MaximoReport.ActualStartDate)>=DateAdd("h",-11.8,[Enter the start date])
-
AND (MaximoReport.ActualStartDate)<DateAdd("h",23,[Enter the end date])))
-
GROUP BY MaximoReport.[Assigned Owner Group];
8 1275
Similar to yours, but try this (I can't vouch for my parentheses): - SELECT MaximoReport.[Assigned Owner Group],
-
Sum(IIf([MaximoReport].[Status] Like "*COMP", 1, 0)) AS CompleteWorkOrders,
-
Sum(IIf([MaximoReport].[Status]<>"CAN", 1, 0)) AS TotalWorkOrders,
-
Round(CompleteWorkOrders/CompleteWorkOrders*100, 1) AS PercentCompleted
-
FROM MaximoReport
-
WHERE (((MaximoReport.WorkType) In ("PMINS","PMOR","PMPDM","PMREG","PMRT"))
-
AND (((MaximoReport.[Target Start])>=DateAdd("h",-1,[Enter the start date])
-
And (MaximoReport.[Target Start])<DateAdd("h",23,[Enter the end date]))
-
AND ((MaximoReport.ActualLaborHours)<>"00:00")
-
AND ((MaximoReport.ActualStartDate)>=DateAdd("h",-11.8,[Enter the start date])
-
And (MaximoReport.ActualStartDate)<DateAdd("h",23,[Enter the end date])))
-
GROUP BY MaximoReport.[Assigned Owner Group];
when i do that it doesnt get the right results for department presentages
The numbers are not coming out is there a better way to do what im trying if i run the department queries seperate they work but when i try to do it with one query the numbers dont match.
I trust that your response is correct. However, how do you know that the values are incorrect? What indicators do you have that the total work orders and the total complete work orders are not being counted correctly.
This is what troubleshooting is all about.
I.e., which records are being missed that should be included or which records are included that should be excluded? Then, after you look at those records, we determine how to include/exclude them....
Because i took the cheese department and calculated the cheese department which is 159/184 and i 86.41 but when i run the queries with all the drpartments i get 95.2
And what are those same values with the new query (not just the percentage)? Which records are missing and why. This is what you need to figure out.
Keep in mind that from this thread and previous threads concerning this group of queries. I am still confused by the ActualLaborHours<>“00:00”. I guess, either it is a work order or it’s not. BUT—I don’t really understand what it represents....
I need to count the work orders for each department that is comp ,fcomp with actual labor hours that the work order was complete not in 00:00 and between the the start date and end date.
However, you’re still not telling us which records are being included or excluded, based upon the query.
When asked a specific question, please provide an answer.
Based upon the queries you provided, it “appears” the the only differences between the queries is the actual start/stop dates and the ActualLaborHours.... It would seem logical that you would want to compare apples to apples and not apples to oranges.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Frank.Sebesta |
last post by:
I would like to run two queries together with the results together in
one report.
I would also want to extract only the duplicate records or have only
the duplicate record show up in the results....
|
by: kevcar40 |
last post by:
Hi
i have a table which records the number of cards issued to a team
fields are
Team text
Numof yellow integer
numor Red integer
date yellow short...
|
by: cody |
last post by:
Hi, I have multiple Collections which I want to iterate over *without*
copying alle my collections into one.
If there is no method to do this I propose a new Class Enumerate which
should provide...
|
by: Benny Schudel |
last post by:
Howto put these two queries together?
sql = "SELECT DISTINCT medium_id, COUNT(tag) AS count FROM tags WHERE
tag = 'test' GROUP BY medium_id ORDER BY count DESC"
This query is working.
Id...
|
by: Ian Davies |
last post by:
Hello
I am trying to update a session, ie everytime the page is resubmitted I want
the current selected value from a list to be appended to the old session
value. I have the following code but am...
|
by: listerofsmeg01 |
last post by:
Hi,
Pretty new to PHP and MySQL.
I have a page on my site that displays a lot of information from
various tables. Currently I have lots of small PHP wrapper functions
around SQL queries to...
|
by: atiq |
last post by:
I am tyring to join two join fields together in a Report in the follwoing format:
Date:
Time:
i have attempted this using the following code, but doesnt work:
="Date:" & " " & & "
" &...
|
by: nsymiakakis |
last post by:
Hi everyone, I have two seperate queries that work great individually, but I need to join them together to get a combined output. Can someone look at these and help me with the code? Here are the 2...
|
by: Serenityquinn15 |
last post by:
Hi!
I have a problem in my query... I want to join my two tables with the same date and returns in different records but it returns duplicate record..
Here is the examples:
Table1:
Field1 ...
|
by: Vasago |
last post by:
I have a couple different tables(time work and Scheduled time) that are coming together to give employees actual worked times and their scheduled times to work. The first queries uses (date...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
|
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...
|
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...
| |