John Ellis
asked on
T-SQL: Eliminating Records Based on Criteria
Hello:
Please review the screenshot embedded at the end.
I want to eliminate records where [DaysLate] > 0 but only where [DocumentType] is not in 'Scheduled Payments', 'Credit Memo', 'Return', or 'Payment'.
I did not know what to do but to use the clause shown below that is above my screenshot.
But, when I do this, SQL eliminates all records of 'Scheduled Payments', 'Credit Memo', 'Return', 'Payment'. I want to keep all of those records.
As far as other records are concerned, I want them gone if they are 0 or less.
How can I make this happen?
Thanks!
John
Please review the screenshot embedded at the end.
I want to eliminate records where [DaysLate] > 0 but only where [DocumentType] is not in 'Scheduled Payments', 'Credit Memo', 'Return', or 'Payment'.
I did not know what to do but to use the clause shown below that is above my screenshot.
But, when I do this, SQL eliminates all records of 'Scheduled Payments', 'Credit Memo', 'Return', 'Payment'. I want to keep all of those records.
As far as other records are concerned, I want them gone if they are 0 or less.
How can I make this happen?
Thanks!
John
HAVING (CASE WHEN [DocumentType] not in ('Scheduled Payments', 'Credit Memo', 'Return', 'Payment') THEN [DaysLate] ELSE 0 END) > 0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.