title: How to use If Statement in Where Clause in SQL?
body: <p>I need to use if statement inside where clause in sql.</p>
  
  <pre><code>Select * from Customer
  WHERE  (I.IsClose=@ISClose OR @ISClose is NULL)  
  AND    
  (C.FirstName like '%'+@ClientName+'%' or @ClientName is NULL )    
  AND 
   if (@Value=2)
    begin
    (I.RecurringCharge=@Total  or @Total is NULL )    
    end
   else if(@Value=3)
  begin
  (I.RecurringCharge like '%'+cast(@Total as varchar(50))+'%' or @Total is NULL )  
  end
  </code></pre>
  
  <p>Note:This is not the complete code.Everything is defined in SP.I Just written the code that was needed to understand the issue.</p>
  
  <p>Thanks in advance.</p>