SUM() with CASE condition

PHOTO EMBED

Thu Sep 15 2022 15:22:33 GMT+0000 (Coordinated Universal Time)

Saved by @javicinhio #sql

Select SUM(CASE When CPayment='Cash' Then CAmount Else 0 End ) as CashPaymentAmount,
       SUM(CASE When CPayment='Check' Then CAmount Else 0 End ) as CheckPaymentAmount
from TableOrderPayment
Where ( CPayment='Cash' Or CPayment='Check' ) AND CDate<=SYSDATETIME() and CStatus='Active';
content_copyCOPY

https://stackoverflow.com/questions/20935265/select-query-with-case-condition-and-sum