All,
Found the solution, the only problem was P.Pattern needed to be Rtrim
in combination with the other condition
SELECT p.pattern, d.ponumber, convert(varchar,h.DOCDATE,106) as PODate,
d.itemnmbr, d.itemdesc, d.qtyorder, d.unitcost, d.extdcost,
d.vendorid, r.vendname, c.cmmttext
FROM...