This is the query using 1 table.
select hrtemno, hrtdpcd, hrttodt, hrtgpno from hraact where hrttrtp IN ('p','l')
intersect select hrtemno, hrtdpcd, hrttodt, hrtgpno from hraact where hrttrtp = 'm'
select hrtemno, hrtdpcd, hrttodt, hrtgpno from hraact where hrttrtp IN ('p','l')
intersect select hrtemno, hrtdpcd, hrttodt, hrtgpno from hraact where hrttrtp = 'm'
Comment