Redshift SQL Case Statement and WHERE Clause not working
<p>I'm running the following SQL script to create a table with information on which marketing efforts are driving people to my site for form fills. </p>

<p>The case statement for marketing source stamp does not work. My results still have values for search-brand-whatever for the marketing_source column when those values should now just read "google-adwords".</p>

<p>I'm also getting results with a createddate of 9/15/2015 and after when my filter clearly states createddate >= '1/1/2016'.</p>

<p>Any ideas? </p>

<pre><code>create table temp.roi_inqs as (
Select 
a.ID,
cast(a.createddate as date) as date,
CASE
WHEN a.marketing_source_stamp__c = 'search%' then 'google-adwords'
ELSE a.marketing_source_stamp__c
END AS marketing_source,
CASE 
when a.contactid is null then b.email
when a.contactid is not null then c.email
end as prospect_email
from rjm_current.sf_campaignmember a
left join rjm_current.sf_lead b on b.id = a.leadid
left join rjm_current.sf_contact c on c.id = a.contactid
where cast(a.createddate as date) &gt;= '1/1/2016'
AND (
campaign_marketing_type__c in ('A','C'))
OR
(campaign_marketing_type__c = 'B'
AND a.status in ('Registered','Attended','No Show')));
</code></pre>

<p><a href="https://i.stack.imgur.com/IfyaO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IfyaO.png" alt="enter image description here"></a></p>