Verify Primary contact for Active companies

SELECT REL.BO_ID_2,COUNT(1) FROM PS_BO_REL REL,PS_BC COMP
WHERE REL.END_DT>GETDATE() AND REL.REL_TYPE_ID=9
AND REL.BO_ID_2 = COMP.BO_ID AND COMP.CUST_STATUS='A'
GROUP BY REL.BO_ID_2
HAVING COUNT(1)>1

No comments:

Post a Comment