Hi,
I already created a query for my alert, hope it can help you out.
Select D.DOCNUM AS 'SO NUMBER',D.DocTotal AS 'TOTAL',sum(D.PaidToDate) AS 'DOWN PAYMENT AMOUNT'
FROM (select c.Doctotal,A.PaidToDate,C.DocNum
from ODPI a
left join DPI1 b on a.DocEntry=b.docentry
left join ORDR c on b.BaseEntry=c.DocEntry
left join RDR1 d on c.DocEntry=d.DocEntry
where
b.BaseType='17' and
c.CANCELED<>'Y' and
a.canceled<>'Y' AND
C.DocStatus<>'C' and
d.TargetType='-1'
group by C.DocNum,C.DocTotal,a.PaidToDate) D
group by d.DocTotal,d.DOCNUM
having (SUM(d.PaidToDate)/D.DocTotal)>='0.25'
Regards,
Lean