title: How to use case statement by comparing two string inside where clause in sql
body: <p>I need to compare two strings if they are same means needs to take one where condition else takes another condition but this code not worked for me.
  Any corrections and suggestions welcomed.
  here I have tried so far.</p>
  
  <pre><code>declare @s1 varchar(10) = '2018',@s2 varchar(10) = '2019'
  Select  PersonalAbwesenheiten.PersonalNr,sum(PersonalAbwesenheiten.AnzahlTage) as totaltakenleaves from PersonalAbwesenheiten 
    Join Personal On personal.PersonalNr = PersonalAbwesenheiten.personalNr and PersonalAbwesenheiten.PersonalNr = 4 and PersonalAbwesenheiten.Status = 4
    and  PersonalAbwesenheiten.Abwesenheitstyp = 1
    where
  
     case when @s1 = @s2 Then
  
     '2019-01-01' &lt;= DatumBis And DatumVon &lt;= '2019-12-31'
  
     when @s1 &lt;&gt; @s2 Then
     '2018-12-30' &lt;= DatumBis And DatumVon &lt;= '2019-01-05'
     end
  
  
      group by PersonalAbwesenheiten.PersonalNr
  </code></pre>