title: Applying the MIN aggregate function to a BIT field
body: <p>I want to write the following query:</p>
  
  <pre><code>SELECT   ..., MIN(SomeBitField), ...
  FROM     ...
  WHERE    ...
  GROUP BY ...
  </code></pre>
  
  <p>The problem is, <s>SQL Server does not like it, when I want to calculate the minimum value of a bit field</s> it returns the error <code>Operand data type bit is invalid for min operator</code>.</p>
  
  <p>I could use the following workaround:</p>
  
  <pre><code>SELECT   ..., CAST(MIN(CAST(SomeBitField AS INT)) AS BIT), ...
  FROM     ...
  WHERE    ...
  GROUP BY ...
  </code></pre>
  
  <p>But, is there something more elegant? (For example, there might be an aggregate function, that I don't know, and that evaluates the logical <code>and</code> of the bit values in a field.)</p>