Sum a case statement in SQL data source
trying to group and sum up a case statement, but keeps erroring out (Failed to retrieve data. Error ticket#.....). tried moving the parentheses around, but nothing's working. below is my query, any ideas?
WHEN A. TRANSACTION_TYPE = 'Sales Order' AND B. ACCOUNT_ID = '124' THEN B. AMOUNT
WHEN A. TRANSACTION_TYPE in ('Invoice','Credit Memo') AND B. ACCOUNT_ID = '453' THEN B. AMOUNT
ELSE 0 END) as 'Header Amount'
FROM TRANSACTIONS A
LEFT JOIN TRANSACTION_LINES B on A. TRANSACTION_ID = B. TRANSACTION_ID
A. TRANDATE > '2017/08/15' AND
A. TRANSACTION_TYPE in ('Invoice','Sales Order','Credit Memo')