I am trying to write a Case When statement with two conditions. In addition it has to be a MAX value since I am grouping everything by a field.
I have tried the code:
Max(Case When InsOrd=1 then When PtBal=Balance then 0 else Balance end) as InsBal1,
Max(Case when InsOrd =2 then when PtBal =Balance then 0 else Balance end) as InsBal2,
max(Case when InsOrd =3 then When PtBal=Balance then 0 else Balance end) as InsBal3,
I get errors that the WHEN is not correct.
The Balance or Zero value should output to InsBal1,2,3 depending on the InsOrd value.