I am using two case statements in a simple select statement like so:
CASE WHEN tblD.Type = 'CL'THEN
SUM(tblD.Amount) END AS SumOfAmount,
CASE WHEN tblD.Type = 'CP'THEN
SUM(tblD.Amount) END AS SumOfPayments
However what I need to do in the 2nd case statement is to only do the sum when the result of the 1st case statement is <> 0.
So the 2nd case statement would become something like this:
CASE WHEN tblD.Type = 'CP'AND
SumOfAmount <> 0 THEN
SUM(tblD.Amount) END AS SumOfPayments
Is this possible?
CASE WHEN tblD.Type = 'CL'THEN
SUM(tblD.Amount) END AS SumOfAmount,
CASE WHEN tblD.Type = 'CP'THEN
SUM(tblD.Amount) END AS SumOfPayments
However what I need to do in the 2nd case statement is to only do the sum when the result of the 1st case statement is <> 0.
So the 2nd case statement would become something like this:
CASE WHEN tblD.Type = 'CP'AND
SumOfAmount <> 0 THEN
SUM(tblD.Amount) END AS SumOfPayments
Is this possible?