title: Aggregate function with image data type
body: <p>What is the best way to perform an aggregate function on an <a href="https://technet.microsoft.com/en-us/library/ms187993(v=sql.105).aspx" rel="nofollow"><code>image</code></a> data type?</p>
  
  <p>For example, where binImage is <code>image</code> data type, and I want to return either binImage or null:</p>
  
  <pre><code>max( case when somechar = 'A' and anotherchar = 'B' then binImage else null end ) as result
  </code></pre>
  
  <p>... will not work, because <a href="https://msdn.microsoft.com/en-us/library/ms187751.aspx" rel="nofollow"><code>max</code></a> does not support the image data type.</p>
  
  <p>I know that <a href="https://technet.microsoft.com/en-us/library/ms187993(v=sql.105).aspx" rel="nofollow"><code>image</code></a> is depreciated.</p>