I have a situation where the table I'm using stores all quantities as a positive values. A "Sales" record would have document type = 1 with a positive quantity value and a return would have a document type = 2 with a positive quantity value.
I'd like to use a sql statement in my stored proc to add the quantities for all "Sales" records within a date range, then subtract all quantities for "Returns" records within that same date range to establish a net sales quantity.
I'm thinking of a case statement, but I suppose a subquery could work also.
I've you done similar, I would like to see how you accomplished this.