I will absolutely use this as a reference and hopefully it will trigger an idea. Thank you for your help!
A.S. Bearden, GDIT
Original Message:
Sent: 08-01-2023 11:44
From: NORMA RAMEY
Subject: SQL statement turn into Where Clause
Hi Adam,
A little late to the party, but I had created a Chart Report counting the number of WO in each status. Did this using COUNT() then charted using a pie chart for results. Simple, but maybe will trigger some ideas for you.
var whereTxt = new String();
whereTxt = "where " + params["where"];
whereTxt = whereTxt +" and workorder.status <> 'CLOSE' ";
var sqlText = new String();
// Add query to sqlText variable.
sqlText = "select status, count(1) as total_count from workorder "
// Include the Maximo where clause
+ whereTxt
+ " group by status order by status"
;
------------------------------
NORMA RAMEY
Original Message:
Sent: 07-27-2023 13:04
From: Adam Bearden
Subject: SQL statement turn into Where Clause
I guess my next question would be, in QBR how would I calculate days between status date and changedate? I can calculate MAXIMUM(statusdate) or MAX(changedate) but doesn't seem to count days between. I used TIMESTAMPDATEDIFF as an expression however, it doesn't seem to work either.
------------------------------
Adam Bearden
GDIT
Original Message:
Sent: 07-27-2023 13:00
From: Adam Bearden
Subject: SQL statement turn into Where Clause
So QBR seems sufficient as I was able to create a where that will list each status of the work order. Just can't seem to get the calculations to start. But, so far; this is looking pretty good.
Maximum(Status Date): | Jul 30, 2019, 4:01 PM | |
|
---|
Work Order: | 4639330 | Status: | CLOSE | Changed Date: | 2/21/17 | 7:06:29 AM | | |
|
|
Maximum(Status Date): | Jul 26, 2019, 11:59 AM | |
|
Crew | Status Date | Changed Date | | Status | days in status | |
MYCREW | 7/26/19 | 11:59:46 AM | 7/26/19 | 12:00:36 PM | | | CLOSE | 0 | |
MYCREW | 7/26/19 | 11:59:46 AM | 7/26/19 | 12:00:36 PM | | | APPR | 0 | |
MYCREW | 7/26/19 | 11:59:46 AM | 7/26/19 | 12:00:36 PM | | | ACCEPT | 0 | |
MYCREW | 7/26/19 | 11:59:46 AM | 7/26/19 | 12:00:36 PM | | | WAPPR | 0 | |
| | | | | | | | | |
|
Crew | Status Date | Changed Date | | Status | days in status | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | CLOSE | 0 | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | MATRECVD | 0 | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | WMATL | 0 | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | WAPPR | 0 | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | APPR | 0 | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | ACCEPT | 0 | |
MYCREW | 7/9/19 | 1:38:19 PM | 7/9/19 | 1:38:31 PM | | | INPRG | 0 | |
| | | | | | | | | |
|
Crew | Status Date | Changed Date | | Status | days in status | |
MYCREW | 7/12/19 | 12:49:45 PM | 7/12/19 | 12:50:01 PM | | | INPRG | 0 | |
MYCREW | 7/12/19 | 12:49:45 PM | 7/12/19 | 12:50:01 PM | | | APPR | 0 | |
MYCREW | 7/12/19 | 12:49:45 PM | 7/12/19 | 12:50:01 PM | | | ACCEPT | 0 | |
MYCREW | 7/12/19 | 12:49:45 PM | 7/12/19 | 12:50:01 PM | | | WAPPR | 0 | |
MYCREW | 7/12/19 | 12:49:45 PM | 7/12/19 | 12:50:01 PM | | | CLOSE | 0 | |
| | | | | | | | | |
|
Crew | Status Date | Changed Date | | Status | days in status | |
MYCREW | 7/30/19 | 4:01:18 PM | 7/30/19 | 4:01:23 PM | | | ACCEPT | 0 | |
MYCREW | 7/30/19 | 4:01:18 PM | 7/30/19 | 4:01:23 PM | | | APPR | 0 | |
MYCREW | 7/30/19 | 4:01:18 PM | 7/30/19 | 4:01:23 PM | | | WAPPR | 0 | |
MYCREW | 7/30/19 | 4:01:18 PM | 7/30/19 | 4:01:23 PM | | | CLOSE | 0 | |
| | | | | | | | | |
|
Crew | Status Date | Changed Date | | Status | days in status | |
MYCREW | 7/22/19 | 1:43:37 PM | 7/22/19 | 1:43:39 PM | | | AWGA | 0 | |
MYCREW | 7/22/19 | 1:43:37 PM | 7/22/19 | 1:43:39 PM | | | ACCEPT | 0 | |
MYCREW | 7/22/19 | 1:43:37 PM | 7/22/19 | 1:43:39 PM | | | APPR | 0 | |
MYCREW | 7/22/19 | 1:43:37 PM | 7/22/19 | 1:43:39 PM | | | WAPPR | 0 | |
MYCREW | 7/22/19 | 1:43:37 PM | 7/22/19 | 1:43:39 PM | | | CLOSE | 0 | |
MYCREW | 7/22/19 | 1:43:37 PM | 7/22/19 | 1:43:39 PM | | | APPR | 0 | |
------------------------------
Adam Bearden
GDIT
Original Message:
Sent: 07-27-2023 10:52
From: Charles Smith
Subject: SQL statement turn into Where Clause
If I am reading this correctly... Are you are looking for the number of days between work order status changes?
If so, then I have a very similar report...
I use Work Order Status table to look at status changes / dates.
I use Lead/Lag function to calculate previous status / date to current status / dates.
LAG(WOSTATUS.CHANGEDATE) OVER ... as Previous status/date
WOSTATUS.CHANGEDATE as current status/date
Current Status/date minus Previous (Lag formula) status/date
However, this is in a Birt report, not in QBR or Maximo output.
------------------------------
Charles Smith
SilverEdge
Original Message:
Sent: 07-27-2023 09:16
From: Adam Bearden
Subject: SQL statement turn into Where Clause
Dragos,
A customer is wanting to track status' ('WAPPR','INPRG','ON HOLD','SCHEDULE','CLOSE','COMP') to look for bottlenecks in his org. He'd like a Result Set that will list each status on the Result Set and the days in each status. I'd like the Result Set to look similar to this:
WONUM | Asset | Description | WAPPR | SCHED | INPROGRESS | ON HOLD | WMTL | MATRCD | COMP | CLOSED |
|
|
| | | | | | | | | | |
|
|
123456 | 1XYZ | Thingamabob | 2 | 2 | 5 | 1 | | | 2 | 1 |
|
|
2456789 | T001358 | Press | 1 | 1 | 2.12 | 0 | 25 | 2 | 2 | 1 |
|
|
With the select, we were able to list each work order by 'WOGROUP' (eliminating each work order number as there would be thousands). Basically, I'm trying to pull the Work Order History data into a Result Set and all I have to work off of is the select and this select will capture the data we need in SQL. Problem is, customers do not have access to SQL so a Result Set will have to do. Hopefully you have a better understanding.
Thank you for replying,
Adam
------------------------------
Adam Bearden
GDIT
Original Message:
Sent: 07-27-2023 09:03
From: Dragos Chitu
Subject: SQL statement turn into Where Clause
Hi Adam,
In Maximo, "where clause" is that part of SQL statement which is coming after "where".
The part before "where" is implied from the Maximo application used and the fields in the List view.
E.g.: in WOTRACK app, if I'm putting into Where clause the string:
siteid = 'BEDFORD' and status = 'COMP'
Maximo implies the following SQL statement:
select wonum, description, location, status, siteid [other-fields-List-View] from workorder where siteid = 'BEDFORD' and status = 'COMP'
Of course, you won't see "select wonum, description, location, status, siteid [other-fields-here] from workorder" part, but Maximo will consider it as such.
In the example that you presented there is basically no "where" part.
And it's not very clear what exactly you want to get with that selection.
I think that easier would be to define what you really want to get and to start from there.
Thank you,
Dragos
------------------------------
Dragos Chitu
EL
Original Message:
Sent: 07-26-2023 13:39
From: Adam Bearden
Subject: SQL statement turn into Where Clause
Wondering if anyone can help me insert this select statement as a where clause. I cannot seem to figure this one out. The select statement works but I'm stumped as to how to modify the code into a where clause. Problem is I do not know where to capture all of the select for the where....if that makes sense. Here is the select.
select SITEID, ORGID, WONUM, CALNUM, STATUS, CHANGEDATE, NEXT_CHANGEDATE,
--to_char(CHANGEDATE,'YYYYMMDD HH24:MI:SS') CHANGEDATE,
--to_char(NEXT_CHANGEDATE,'YYYYMMDD HH24:MI:SS') NEXT_CHANGEDATE,
ASSET_UTILITIES.CALENDAR_TIME_HOURS
(ORGID, CALNUM, CHANGEDATE, NEXT_CHANGEDATE, CHANGEDATE, NEXT_CHANGEDATE) STATUS_HOURS
from (
select W.WONUM, W.SITEID, W.ORGID, W.ASSETNUM, A.CALNUM, S.STATUS, S.WOSTATUSID,
S.CHANGEDATE,
nvl(lead(S.CHANGEDATE) over ( order by S.WONUM, S.SITEID, S.CHANGEDATE, S.WOSTATUSID),
sysdate) NEXT_CHANGEDATE
from WORKORDER W
left join ASSET A
on W.ASSETNUM = A.ASSETNUM
and W.SITEID = A.SITEID
left join WOSTATUS S
on W.WONUM = S.WONUM
and W.SITEID = S.SITEID
where W.WONUM in ( '624671','624672','624673','624674')
and W.SITEID = 'LEAD'
) A
order by WONUM, SITEID, CHANGEDATE, WOSTATUSID
Thank you in advance.
Adam
#EndUser
#EverythingMaximo
#Reporting
#WorkManagement
------------------------------
Adam Bearden
GDIT
------------------------------