SQL Server Amount "Open" At Each Month End -
i need create query sum amount of open accounts receivable each month.
each record in table has amount,posting date, , closed @ date. example, 1 record might be: amount : 5000, posting date : 1/1/15, closed @ date : 3/5/15. record, 5000 need added january open ar calculation because open of 1/31/15, added february open ar calculation because open of 2/28/15, excluded march open ar calculation because closed of 3/31/15.
i have managed create query work individual month, given single inputted month-end date, i.e. 1/31/15 or 2/28/15, etc..., goes clause.
select sum(amount), threemonthavg, sum(amount)/threemonthavg dso tbl1 postdate <= @enddate , closeddate > @enddate
am on right track expand out include each month in 1 query or better off taking have, , creating stored procedure run query each month , union results together?
Comments
Post a Comment