JBM2015
asked on
SQL Case statement to determine to add or subtract quantity
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.
Thanks
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.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER