W D
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,QtyC ycleCounte d, QtyDamaged, QtyRecycled, EndQOH
Sometimes records have all 0's in the qty fields: BeginningQOH, QtyReceived, QtyPicked,QtyReturned,QtyC ycleCounte d, 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?
The report includes these fields:
ProductNumber, ProductName, BeginningQOH, QtyReceived, QtyPicked,QtyReturned,QtyC
Sometimes records have all 0's in the qty fields: BeginningQOH, QtyReceived, QtyPicked,QtyReturned,QtyC
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
pssandhu, the series of OR statements work!
I just went through the report results and they were correct.
I just went through the report results and they were correct.
P.