Hi aliya. The first thing you need to do is to start formatting your code so that it is readable. That would certainly have saved me some time. Not reusing c and d as aliases in the last sub-query would remove another source of confusion. Then you need to read the doco and learn to use the query analyzer, because it is an awesome tool, and will tell you everything you need to know to solve this problem.
As you suggest, however, the problem is almost certainly in the final self-join sub-query. This is an uncorrelated sub-query, so the complete result set of the sub-query, for EVERY value of itemno / pitmn, will be generated again for EVERY candidate row of the outer a,b,c,d join. This is what you currently have:
This is semantically equivalent code which should run a great deal faster:
The g.pitmn = h.pitmn condition might not be necessary, I'm not sure. Note that
you should have an index on pitmn, and that a composite index on (pitmn, palph1) would probably be even better. You might also like the try the following version, which might be even better:
BTW, you didn't mention an index on d.isgrup. That would probably be useful as well.