Most important, do you have an index on transaction that consists of item, version and lasttran? You need lasttran included to make the index work. I think that’s the problem.
What may be beneficial is to create a work file containing the last transaction of each item in the warehouse. Then create an index on that work file. Much smaller, yes? Then:
select min(loc) FirstLocaion, item, version, lasttran
left join (select item2, version2, lasttrans
from workfile) on item=item2 and version=version2
I don’t think you will need the grouping.
I don’t understand why the min(loc).
Put the solution here when you have it.