Link to home
Start Free TrialLog in
Avatar of JBM2015
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
SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JBM2015
JBM2015

ASKER

Thank You, I'll give those a try.