It the "item" is an Asset, then you will find data in the ASSETTRANS object in the DB. Since you know the current asset and the location, you can find the immediate predecessor in the ASSETTRANS object (sorting on
datemoved.) Using DB2 SQL against MAXDEMO DB here is what I believe will get you close to what you want:
with cat (assetnum, datemoved, fromparent, fromloc, toloc) as
(Select fat.assetnum, fat.datemoved, fat.fromparent, fat.fromloc, fat.toloc
from assettrans fat
where fat.toloc = 'BR450'
union all
select tat.assetnum, tat.datemoved, tat.fromparent, tat.fromloc, tat.toloc
from assettrans tat
where tat.fromloc = 'BR450'
)
select * from cat
order by cat.datemoved
You output might look like this then:
I threw this together pretty quick. You may want to play with the
fromloc and
toloc attributes to see what yields the best info (this is not a formal self-join so, the "from" and "to" get kind confusing.) I tested this without actually making any changes (as the dates can attest! Ha!) but I think this is close. If not, I hope it will help you get started down the right road. You could easily use the BIRT reporting capabilities to build a report to allow you to input the location as a parameter.
Hope this helps
------------------------------
Bradley K. Downing , MBA
Solutions Engineer
IBM
Bakersfield CA
------------------------------