- Home /

I want the sum to be zero instead of null in a case statement Case when transactiontypecode = 'ABS' then coalesce(sum(Amt),0) end as ABS , Is there a way around this? Thanks a lot

Comment

Tom Staab

ScottEdwards2000

ScottEdwards2000

Best Answer

**Answer** by Tom Staab ·

Just change the order of operations. Instead of CASE WHEN transactiontypecode = 'ABS' THEN COALESCE(SUM(Amt),0) END AS ABS do SUM(CASE WHEN transactiontypecode = 'ABS' THEN Amt ELSE 0 END) AS ABS

Copyright 2019 Redgate Software.
Privacy Policy

- Anonymous
- Sign in
- Create
- Ask a question
- Spaces
- Site Issues (NOT FOR DATABASE QUESTIONS)
- Explore
- Topics
- Questions
- Users
- Badges