title: Aggregate Function on Uniqueidentifier (GUID)
body: <p>Let's say I have the following table:</p>
  
  <pre><code>category | guid
  ---------+-----------------------
     A     | 5BC2...
     A     | 6A1C...
     B     | 92A2...
  </code></pre>
  
  <p>Basically, I want to do the following SQL:</p>
  
  <pre><code>SELECT category, MIN(guid)
    FROM myTable
   GROUP BY category
  </code></pre>
  
  <p>It doesn't necessarily have to be MIN. I just want to return <em>one</em> GUID of each category. I don't care which one. Unfortunately, SQL Server does not allow MIN or MAX on GUIDs.</p>
  
  <p>Of course, I could convert the guid into a varchar, or create some nested TOP 1 SQL, but that seems like an ugly workaround. Is there some elegant solution that I've missed? </p>