Multiple Conditions in a CASE statement

Hi there,

Can someone help stop me from going mad please?!

I am trying to compare 2 conditions in a single case statement. As follows: -

First part of the case statement is pulling in a date when a particular 'activity' is recorded in another table. This on it's own works fine: -


Case when (RRPP.ActivityCategory) = 'RRPP' then RRPP.ActivityEnteredDate else NULL end as 'RRPP Activity Date',

Whenever I try to add a second condition to my case statement, it doesn't return the expected results, based on what is within my test data


Case when (RRPP.ActivityCategory) = 'RRPP' and RRPP.ActivityEnteredDate between dateadd(d,-90,DP.PolicyRenewalDate) and dp.policyrenewaldate then RRPP.ActivityEnteredDate else NULL end as 'RRPP Activity Date',

I get no queries when I run my query, but based on my test data I do not get the expected outcome. I am guessing there is some issue with the highlited section, but I am not entirely sure what I am doing wrong.

Does anyone have any pointers?

Thanks in advance

Glenn

Aaaaaah,

my renewal date that was being compared against was actually set to a 2018 date rather than the 2017 date I thought it was. So basically, it's my fault, not SQLs. Which is usually the case.

Sorry :slight_smile: