Display Running Gross Sales Numbers for a Period

— Display Running Gross Sales Numbers for a Period

— Variables Below …
— Replace the XX in month(glpostdt) to the period number you desire
— Replace the XXXX in year(glpostdt) to the year you desire
— Soptype 3 is all posted invoices
— Soptype 4 is all posted returns

select CUSTNMBR, custname, sopnumbe, glpostdt,
CASE SOPTYPE
when 3 then ((ORSUBTOT + ORMISCAMT) – ORTDISAM)
when 4 then ((ORSUBTOT + ORMISCAMT) – ORTDISAM) *-1
end
Sales
from sop30200
where month(glpostdt) = ‘XX’ and year(glpostdt) = ‘XXXX’ and soptype in (‘3′,’4’)