title: Simple SELECT QUERY WITH Equal or Not EqualTo a Value
body: <p>Let say I have this table,</p>
  
  <pre><code>A    B
  -------
  1    A
  2    C
  3    A
  4    NULL
  5    B
  6    A
  </code></pre>
  
  <p>I have only a single parameter in stored procedure. I need to pass a single parameter <code>@param</code>. I need to select all rows equal to <code>A</code> or select all rows not equal to <code>A</code>. I have only a single parameter <code>@param</code>. If  <code>@param</code> = 'A' select all rows with A and If  <code>@param</code> &lt;> 'A' select all rows with not equal to A.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is 1 approach I have found. <strong>Not sure</strong> which approach is <strong>best one</strong>.</p>
  
  <pre><code>DECLARE @Param VARCHAR(5)='NOt A'
  
  DECLARE @tbl TABLE(A INT,B VARCHAR(5))
  
  INSERT INTO @tbl(A,B)
  VALUES
      (1,'A'),
      (2,'C'),
      (3,'A'),
      (4,NULL),
      (5,'B'),
      (6,'A')
  
  SELECT  * 
  FROM    @tbl 
  WHERE 1 = 
          (
              CASE    WHEN @param = 'A' 
                      THEN 
                      (
                          CASE WHEN B = 'A' THEN 1 ELSE 2 END
                      ) 
                      ELSE 
                      (
                          CASE WHEN (B IS NULL OR B &lt;&gt; 'A') THEN 1 ELSE 2 END
                      ) 
                      END
          ) 
  </code></pre>