title: How to avoid or enable geography field in group by in SQL Server 2012?
body: <p>How can I calculate the distance between the given Point and the database users.GeoLocation in the select statement. I need the group by clause (This query is simplified.). But SQL Server is complaining:</p>
  
  <p>The type "geography" is not comparable. It cannot be used in the GROUP BY clause.</p>
  
  <p>If I remove it from the group by clause it also complains.
  What to do? Conversion to another field type somehow?</p>
  
  <pre><code>SELECT    geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326).STDistance(users.GeoLocation) AS distanceKM,                    
            users.ID
  FROM      users_Users AS users
  GROUP BY  users.ID,
            users.GeoLocation
  </code></pre>