Subject never mind previous
Author Dixon Epperson
I figured it out,

Here is what the query should be, but is there a more efficient way to
do this?

SELECT c1.CO_IDNUM, c1.CO_NAME,
(SELECT SUM(s2.SA_TOTAL- COALESCE(
(SELECT SUM(y1.YD_AMTAPLD) FROM PAYDETAIL y1 JOIN PAYREGISTER r1 ON
(y1.YD_NUM=r1.PY_NUM)
WHERE (y1.YD_INV=s2.SA_INVOICE AND y1.YD_VOID='0' AND r1.PY_DATE <=
'11/23/04')),0))
FROM SALESREG s2 WHERE (s2.SA_INVDATE > '10/23/04') AND
s2.SA_VOID='0' AND s2.SA_CUSTID = c1.CO_IDNUM)


FROM SALESREG s1 LEFT JOIN COMPANY c1 ON (s1.SA_CUSTID = c1.CO_IDNUM)
GROUP BY c1.CO_NAME, c1.CO_IDNUM order by c1.co_name