Henry House <hajhouse(at)houseag(dot)com> writes:
> the balance forward of the amount column for the user-suplied date correcly
> unless the user supplies a $startdate such that no culumns are being added.
> In this case NULL is returned.
Yeah, for some unfathomable reason SQL92 defines SUM() of no rows to
return NULL, rather than zero as any mathematician would say it should.
Use COALESCE(SUM(...), 0) to replace the null result by 0.
regards, tom lane