title: Case in where clause gives syntax error in SQL Server 2012
body: <p>I am working on reporting side, when start date and end date is selected the report should display the data between the date range, if  dates are not selected then the report should display all records present in the table.</p>
  
  <p>The below SQL gives syntax error at 1=1:</p>
  
  <pre><code>select  a.PURCH_DOC_DATE from PURCH_SCHED_LINE_FACT a 
   where  
   (case when a.CLIENT_ID='0050' then a.PURCH_DOC_DATE 
         when a.CLIENT_ID='0057' then a.STATS_DELIV_DATE
         else 1=1
  end)
  between  '01-01-2014' and '12.12.2014'
  </code></pre>