title: select an xml type column in select query with group by SQL Server 2008
body: <p>I am writing a select query in which I am fetching several columns (by joining 3-4 tables).
  I use group by clause to group my results.</p>
  
  <p>Query - </p>
  
  <pre><code>    select ci.Candidate_Id, ci.FirstName, ci.DetailXML
  from Candidate_Instance ci 
  where ci.Candidate_Instance_Id=2
  group by 
  ci.Candidate_Id, ci.FirstName, ci.DetailXML
  </code></pre>
  
  <p>One of the tables have a column which is of XML data type. When I add the column in the select list, I get this error - </p>
  
  <p><strong>Column 'table.myXML' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</strong></p>
  
  <p>and when I add the column in the group by clause, I get this error - </p>
  
  <p><strong>The XML data type cannot be compared or sorted, except when using the IS NULL operator.</strong></p>
  
  <p>I am quite confused as to how to come out of this.
  I want to get the XML data from the column.</p>
  
  <p>Thanks</p>