Hi Danny,
It can be used as the basis, just needs tweaking. Here's what I don't like about the SQL code supplied.
1. It relies on the work order as the centre of all transactions and that is just not true. There is a case to be had that an SR has been raised and that the agent starts/stops the timer or time is manually allocated to the SR. Of course, this causes a labtrans entry (LABTRANS.TICKETID). Please don't mistake this for raising an ACTIVITY from SR or INCIDENT as they are work order-based.
2. The SQL has no linkage from the work order to the transaction tables i.e. labtrans.refwo, matusetrans.refwo. I would not reference the work order at all, rather only involve the asset, labtrans and matusetrans all linked via the assetnum and siteid.
3. It has not taken into account that you must link using the SITEID even if you have only one site.
4. It only recognises the regular hours of work and has not factored in the premium hours (LABTRANS.PREMIUMPAYHOURS).
5. It has forgotten that you want the YTD cost + hours. That can be just as simple as year(transdate) = year(sysdate), though the sysdate/getdate()/current_timestamp depends on your database as well as how you get to extract the year. I do have to mention that there is normally the transdate and actualdate, you have to decide which to use. When using financial periods, a user can transact on say the 3rd, but have the actual date as the 30th...of the previous month. This allows for the prior financial period to accumulate the costs in cases where the user forgets to enter the cost on the Friday and chooses to do it on the following Monday.
Asset cost rollup
As pointed out there is the table ASSETROLLUPSTATUS. I would also like to converse about the YTD figures as these used to get populated whenever someone ran the Asset Cost Rollup report and now there is a System Property that can be enabled to automatically add the YTD that you see on the asset. However, I need to point out that unless you are running 'something' that runs the Zero YTD menu action (also on Labor and Inventory) it only means that the cost is from when it was last reset. So be mindful if you're looking at that figure.
------------------------------
Craig Kokay
Cosol
#IBMCahmpion
------------------------------
Original Message:
Sent: 01-03-2024 10:33
From: Danny Richardson
Subject: SQL to obtain YTD Labor Hrs and YTD Cost per Asset
Hello all, I have now been set up with an SQL tool to run database queries.
- Is it possible to run an SQL that will give me the YTD Labor Hours for an asset?
- Also the YTD Material Cost?
Thank you
#Administration
#Analytics
#Assets
#EverythingMaximo
------------------------------
Danny Richardson
Maintenance Administration Facilities
Technimark LLC
------------------------------