0

I have a scenario where I have to use CASE and SUM in an CDS VIEW SQL statement and I cannot add net_val to the group by statement. Is there a way to use CASE and SUM together

case when sum( net_val ) < 0 then 'DEBIT' 
     when sum( net_val ) > 0 then 'CREDIT'
end as DEBIT_CREDIT_STATUS
Philipp
  • 67,764
  • 9
  • 118
  • 153
Nash
  • 99
  • 2
  • 9
  • It's not clear from your question how exactly you want to group the results. Can you add your non-working `GROUP BY` clause to the question and tell us the error message you receive, so we can give you a corrected version? – Philipp Sep 15 '22 at 08:10
  • Does this answer your question? [Aggregated field to use SUM/MIN based on a condition?](https://stackoverflow.com/questions/60523554/aggregated-field-to-use-sum-min-based-on-a-condition) – Suncatcher Oct 07 '22 at 02:18

0 Answers0