I’ve done a CASE WHEN statement in my SQL query but it’s not working for some reason.
I’m not entirely sure what I have done wrong here but it doesn’t seem obvious to me.
CASE WHEN (CPTY_RSK_FCTR_MTHDY_TYP <= 2000) THEN ‘0’
WHEN (CPTY_RSK_FCTR_MTHDY_TYP >= 2001) THEN ‘1’
ELSE ‘0’
END as CV_Doggo,
sum(case when CPTY_RSK_FCTR_MTHDY_TYP <= 2000 THEN ‘0’
WHEN CPTY_RSK_FCTR_MTHDY_TYP >= 2001 THEN ‘1’
ELSE ‘0’
END
) over (CV_Doggo) as Total_CV_Doggo
FROM ia_r_pty @ffdws1p_m.de.db.com
WHERE CPTY_RSK_FCTR_MTHDY_TYP IS NOT NULL;
New contributor
SlickDaddyTDog is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.