Link to home
Start Free TrialLog in
Avatar of W D
W DFlag for United States of America

asked on

Exclude SQL report records with all zero values in transaction fields

I have a complicated SQL report based upon the joining of several tables.
The report includes these fields:
ProductNumber, ProductName, BeginningQOH, QtyReceived, QtyPicked,QtyReturned,QtyCycleCounted, QtyDamaged, QtyRecycled, EndQOH

Sometimes records have all  0's in the qty fields: BeginningQOH, QtyReceived, QtyPicked,QtyReturned,QtyCycleCounted, QtyDamaged, QtyRecycled, EndQOH

I'd like to exclude the records that have all 0's in these fields. I tried using a HAVING statement such as HAVING BeginningQOH  + QtyReceived + QtyPicked + QtyReturned + QtyCycleCounted + QtyDamaged + QtyRecycled + EndQOH > 0

but records such as BeginningQOH = 28, QtyCycleCounted = -28, EndQOH = 0 (the other fields have 0) were left out.

Then I tried using a series of ANDs such as HAVING BeginningQOH > 0 AND QtyReceived > 0 AND QtyPicked > 0, etc but this excluded records that shouldn't be excluded also.

Any thoughts on what I can do to exclude the records that have all 0's in these fields?

Avatar of pssandhu
pssandhu
Flag of Canada image

Can you post your query that you are using please?
P.
ASKER CERTIFIED SOLUTION
Avatar of pssandhu
pssandhu
Flag of Canada 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
Avatar of W D

ASKER

pssandhu, the series of OR statements work!
I just went through the report results and they were correct.