title: SQL Where Clause with CASE & NOT IN Condition
body: <p>I have a select query with where Clause. Now I have to add additional condition in where clause based on user access. If user does not have access then need to include additional condition in where clause, else if user have access then there is no additional logic.</p>
  
  <p>For example:</p>
  
  <pre><code>Select * from TableA where ID &gt; 100
  </code></pre>
  
  <p>Additional Logic:
  If user does not have access to Admin Page then @X= 0 and if does not have access to External Page then @Y = 0.</p>
  
  <p>I need to include the below logic in where clause:</p>
  
  <pre><code>if (@X = 0 and @y=0) then 
  pagecode not in ('admin','external') 
  else if(@x=0 and @y=1) then
  pagecode not in ('admin')
  else if(@x=1 and @y=0) then
  pagecode not in ('external')
  else
  no additional logic in where clause
  </code></pre>
  
  <p>How to implement this using case in where clause.  </p>