We have a situation where we have some Installed Items that for some reason have multiple PM Schedules. I am trying to track these down, but have no luck making a SQL query to find these:

How do I link Item against pm_sched?
We have a situation where we have some Installed Items that for some reason have multiple PM Schedules. I am trying to track these down, but have no luck making a SQL query to find these:

How do I link Item against pm_sched?
Best answer by Phil Seifert
Hi Bjørn,
I have used the below script in the past with other customers to find duplicate PM dates which actually is checking if there are multiple PM dates in the same month:
select * from (
select cl.cconth_id, it.serial_no, cl.pm_sched_id,
LEFT(CONVERT(varchar, pm.last_sched_pm_date,112),6) YYYYMM,
count(it.serial_no) qty
from pm_sched_dates pm with(nolock)
inner join ccontl cl with(nolock) on cl.ccontl_id = pm.ccontl_id
inner join item it with(nolock) on it.item_id = pm.item_id
where (1=1)
and pm.order_id is null
and pm.last_sched_pm_date > '30 April 2020'
and pm.last_sched_pm_date < '1-June-2020'
group by cl.cconth_id, it.serial_no, cl.pm_sched_id, LEFT(CONVERT(varchar, pm.last_sched_pm_date,112),6)
having count(it.serial_no) > 1
) list
order by yyyymm, cconth_id, serial_no
You can see the joins from the ccontl to the pm_sched_date is via the ccontl_id.
There is also a cconth.pm_sched_id and as shown above, the ccontl.pm_sched_id. Perhaps this will help?
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.