SELECT tmpTbl.SID, tmpTbl.CSID, tmpTbl.M,WoOr.QCL, COUNT(epa1), COUNT(epa2)
FROM tmpTbl INNER JOIN WoOr ON tmpTbl.WO = WoOr.WO
GROUP BY tmpTbl.SID, tmpTbl.CSID, tmpTbl.M,WoOr.QCL
is what you want to do. It's not a pivot at all, you're already selecting your columns and doing a group by, so you just want the count within the groups, right ?