Here is a very rough pass at it. Uses summary functions to bring one copy of folderType from fileA with
one copy of a concat field Policy# and Document. You would have to use a second step to break
the concat field apart.
Select A.folderType, min(concat(b.Policy#, b.Document)) from filea join fileB
on A.Policy# = b.Policy# and a.folderType = b.foldertype
Group by A.folderType;
This would be so….oooo much easier in a procedural language like RPG.
Confidence level in the above code 50%.