title: Case statment based on a count
body: <p>I want to do a case statement based on the results of a count.</p>
  
  <p>Something like:</p>
  
  <pre><code>SELECT
      CASE
          WHEN count(distinct column) = 1
              THEN Foo
          WHEN count(distinct column) = 2
              THEN foo2
      END,
      column2
  FROM
      TABLE
  </code></pre>
  
  <p>The above throws errors such as:</p>
  
  <pre><code>Column 'column2' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
  </code></pre>
  
  <p>I've tried a few other variations like this, but to no avail.</p>
  
  <p>Using MS SQL 2005.</p>