Body: <p>I've replicated this on a second Drupal/Civi 4.7.27 site so I don't believe it's limited to me, but could do with a bit of assistance before putting it on JIRA.</p>
  <p>Attempting to create a Case Detail report with the following fields:</p>
  <blockquote>
  <p>[x] Subject</p>
  <p>[x] Client name</p>
  <p>Case type</p>
  <p>Case status</p>
  </blockquote>
  <p>Sorting:</p>
  <blockquote>
  <p>Case Type &gt; Ascending &gt; Section Header/Group by</p>
  <p>Status &gt; Ascending</p>
  <p>Start Date &gt; Ascending</p>
  </blockquote>
  <p>And I then get the following error message. This is <strong>only</strong> replicated with the Section Header/Group By enabled on Case Type.</p>
  <p>Could anyone assist? Errors below:</p>
  <pre><code> Dec 11 14:17:00  [info] $Fatal Error Details = Array
  (
  [callback] =&gt; Array
      (
          [0] =&gt; CRM_Core_Error
          [1] =&gt; handle
      )
  
  [code] =&gt; -19
  [message] =&gt; DB Error: no such field
  [mode] =&gt; 16
  [debug_info] =&gt; SELECT SQL_CALC_FOUND_ROWS case_civireport.id as civicrm_case_id, case_civireport.subject as civicrm_case_subject, case_civireport.start_date as civicrm_case_start_date, case_civireport.status_id as civicrm_case_status_id, case_civireport.case_type_id as civicrm_case_case_type_id, contact_civireport.sort_name as civicrm_contact_client_sort_name, contact_civireport.id as civicrm_contact_id, GROUP_CONCAT(DISTINCT(relationship_civireport.relationship_type_id) ORDER BY relationship_civireport.relationship_type_id) as civicrm_relationship_case_role, civireport_case_types.title as case_type_name , case_civireport.case_type_name as civicrm_case_case_type_name 
           FROM civicrm_case case_civireport
  LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = case_civireport.id
  LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
  
           LEFT JOIN  civicrm_relationship relationship_civireport ON relationship_civireport.case_id = case_civireport.id
  
           LEFT JOIN civicrm_address address_civireport
                  ON contact_civireport.id = address_civireport.contact_id AND
                     address_civireport.is_primary = 1 
      LEFT JOIN civicrm_case_type civireport_case_types
        ON case_civireport.case_type_id = civireport_case_types.id
     WHERE ( case_civireport.is_deleted = 0 )  GROUP BY case_civireport.id  ORDER BY civireport_case_types.title ASC  LIMIT 0, 50 [nativecode=1054 ** Unknown column 'case_civireport.case_type_name' in 'field list']
  [type] =&gt; DB_Error
  [user_info] =&gt; SELECT SQL_CALC_FOUND_ROWS case_civireport.id as civicrm_case_id, case_civireport.subject as civicrm_case_subject, case_civireport.start_date as civicrm_case_start_date, case_civireport.status_id as civicrm_case_status_id, case_civireport.case_type_id as civicrm_case_case_type_id, contact_civireport.sort_name as civicrm_contact_client_sort_name, contact_civireport.id as civicrm_contact_id, GROUP_CONCAT(DISTINCT(relationship_civireport.relationship_type_id) ORDER BY relationship_civireport.relationship_type_id) as civicrm_relationship_case_role, civireport_case_types.title as case_type_name , case_civireport.case_type_name as civicrm_case_case_type_name 
           FROM civicrm_case case_civireport
  LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = case_civireport.id
  LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
  
           LEFT JOIN  civicrm_relationship relationship_civireport ON relationship_civireport.case_id = case_civireport.id
  
           LEFT JOIN civicrm_address address_civireport
                  ON contact_civireport.id = address_civireport.contact_id AND
                     address_civireport.is_primary = 1 
      LEFT JOIN civicrm_case_type civireport_case_types
        ON case_civireport.case_type_id = civireport_case_types.id
     WHERE ( case_civireport.is_deleted = 0 )  GROUP BY case_civireport.id  ORDER BY civireport_case_types.title ASC  LIMIT 0, 50 [nativecode=1054 ** Unknown column 'case_civireport.case_type_name' in 'field list']
  [to_string] =&gt; [db_error: message=&quot;DB Error: no such field&quot; code=-19 mode=callback callback=CRM_Core_Error::handle prefix=&quot;&quot; info=&quot;SELECT SQL_CALC_FOUND_ROWS case_civireport.id as civicrm_case_id, case_civireport.subject as civicrm_case_subject, case_civireport.start_date as civicrm_case_start_date, case_civireport.status_id as civicrm_case_status_id, case_civireport.case_type_id as civicrm_case_case_type_id, contact_civireport.sort_name as civicrm_contact_client_sort_name, contact_civireport.id as civicrm_contact_id, GROUP_CONCAT(DISTINCT(relationship_civireport.relationship_type_id) ORDER BY relationship_civireport.relationship_type_id) as civicrm_relationship_case_role, civireport_case_types.title as case_type_name , case_civireport.case_type_name as civicrm_case_case_type_name 
           FROM civicrm_case case_civireport
  LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = case_civireport.id
  LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
  
           LEFT JOIN  civicrm_relationship relationship_civireport ON relationship_civireport.case_id = case_civireport.id
  
           LEFT JOIN civicrm_address address_civireport
                  ON contact_civireport.id = address_civireport.contact_id AND
                     address_civireport.is_primary = 1 
      LEFT JOIN civicrm_case_type civireport_case_types
        ON case_civireport.case_type_id = civireport_case_types.id
     WHERE ( case_civireport.is_deleted = 0 )  GROUP BY case_civireport.id  ORDER BY civireport_case_types.title ASC  LIMIT 0, 50 [nativecode=1054 ** Unknown column 'case_civireport.case_type_name' in 'field list']&quot;]
  )
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-11T18:16:44.580Z
Comments.Text: Would it be worth replicating on dmaster.demo.civicrm.org? Usually a good step before JIRA. Though seems to be non-functioning currently
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-11T18:28:40.533Z
Comments.Text: Have replicated it on Circle Interactive's demo site (https://demo.circle-interactive.co.uk) at least, so it's definitely a whole-CiviCRM issue. Awaiting my account approval to post it on JIRA now. My first bug - how exciting!
Comments.UserDisplayName: termdark
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-11T18:33:17.517Z
Comments.Text: Cool. Add the JIRA link as an Answer when you get it, then you can update that answer when it gets a fix.
Comments.UserDisplayName: petednz - fuzion
Tags: <civireport>
Title: CiviReport: Field not found when sorting by Case Type as a section header
ThreadText: # CiviReport: Field not found when sorting by Case Type as a section header
  
  (Asked by: username_0 on 2017-12-11)
  
  I've replicated this on a second Drupal/Civi 4.7.27 site so I don't believe it's limited to me, but could do with a bit of assistance before putting it on JIRA.
  Attempting to create a Case Detail report with the following fields:
  
  [x] Subject
  [x] Client name
  Case type
  Case status
  
  Sorting:
  
  Case Type > Ascending > Section Header/Group by
  Status > Ascending
  Start Date > Ascending
  
  And I then get the following error message. This is only replicated with the Section Header/Group By enabled on Case Type.
  Could anyone assist? Errors below:
   Dec 11 14:17:00  [info] $Fatal Error Details = Array
  (
  [callback] => Array
      (
          [0] => CRM_Core_Error
          [1] => handle
      )
  
  [code] => -19
  [message] => DB Error: no such field
  [mode] => 16
  [debug_info] => SELECT SQL_CALC_FOUND_ROWS case_civireport.id as civicrm_case_id, case_civireport.subject as civicrm_case_subject, case_civireport.start_date as civicrm_case_start_date, case_civireport.status_id as civicrm_case_status_id, case_civireport.case_type_id as civicrm_case_case_type_id, contact_civireport.sort_name as civicrm_contact_client_sort_name, contact_civireport.id as civicrm_contact_id, GROUP_CONCAT(DISTINCT(relationship_civireport.relationship_type_id) ORDER BY relationship_civireport.relationship_type_id) as civicrm_relationship_case_role, civireport_case_types.title as case_type_name , case_civireport.case_type_name as civicrm_case_case_type_name 
           FROM civicrm_case case_civireport
  LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = case_civireport.id
  LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
  
           LEFT JOIN  civicrm_relationship relationship_civireport ON relationship_civireport.case_id = case_civireport.id
  
           LEFT JOIN civicrm_address address_civireport
                  ON contact_civireport.id = address_civireport.contact_id AND
                     address_civireport.is_primary = 1 
      LEFT JOIN civicrm_case_type civireport_case_types
        ON case_civireport.case_type_id = civireport_case_types.id
     WHERE ( case_civireport.is_deleted = 0 )  GROUP BY case_civireport.id  ORDER BY civireport_case_types.title ASC  LIMIT 0, 50 [nativecode=1054 ** Unknown column 'case_civireport.case_type_name' in 'field list']
  [type] => DB_Error
  [user_info] => SELECT SQL_CALC_FOUND_ROWS case_civireport.id as civicrm_case_id, case_civireport.subject as civicrm_case_subject, case_civireport.start_date as civicrm_case_start_date, case_civireport.status_id as civicrm_case_status_id, case_civireport.case_type_id as civicrm_case_case_type_id, contact_civireport.sort_name as civicrm_contact_client_sort_name, contact_civireport.id as civicrm_contact_id, GROUP_CONCAT(DISTINCT(relationship_civireport.relationship_type_id) ORDER BY relationship_civireport.relationship_type_id) as civicrm_relationship_case_role, civireport_case_types.title as case_type_name , case_civireport.case_type_name as civicrm_case_case_type_name 
           FROM civicrm_case case_civireport
  LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = case_civireport.id
  LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
  
           LEFT JOIN  civicrm_relationship relationship_civireport ON relationship_civireport.case_id = case_civireport.id
  
           LEFT JOIN civicrm_address address_civireport
                  ON contact_civireport.id = address_civireport.contact_id AND
                     address_civireport.is_primary = 1 
      LEFT JOIN civicrm_case_type civireport_case_types
        ON case_civireport.case_type_id = civireport_case_types.id
     WHERE ( case_civireport.is_deleted = 0 )  GROUP BY case_civireport.id  ORDER BY civireport_case_types.title ASC  LIMIT 0, 50 [nativecode=1054 ** Unknown column 'case_civireport.case_type_name' in 'field list']
  [to_string] => [db_error: message="DB Error: no such field" code=-19 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT SQL_CALC_FOUND_ROWS case_civireport.id as civicrm_case_id, case_civireport.subject as civicrm_case_subject, case_civireport.start_date as civicrm_case_start_date, case_civireport.status_id as civicrm_case_status_id, case_civireport.case_type_id as civicrm_case_case_type_id, contact_civireport.sort_name as civicrm_contact_client_sort_name, contact_civireport.id as civicrm_contact_id, GROUP_CONCAT(DISTINCT(relationship_civireport.relationship_type_id) ORDER BY relationship_civireport.relationship_type_id) as civicrm_relationship_case_role, civireport_case_types.title as case_type_name , case_civireport.case_type_name as civicrm_case_case_type_name 
           FROM civicrm_case case_civireport
  LEFT JOIN civicrm_case_contact civireport_case_contact on civireport_case_contact.case_id = case_civireport.id
  LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
  
           LEFT JOIN  civicrm_relationship relationship_civireport ON relationship_civireport.case_id = case_civireport.id
  
           LEFT JOIN civicrm_address address_civireport
                  ON contact_civireport.id = address_civireport.contact_id AND
                     address_civireport.is_primary = 1 
      LEFT JOIN civicrm_case_type civireport_case_types
        ON case_civireport.case_type_id = civireport_case_types.id
     WHERE ( case_civireport.is_deleted = 0 )  GROUP BY case_civireport.id  ORDER BY civireport_case_types.title ASC  LIMIT 0, 50 [nativecode=1054 ** Unknown column 'case_civireport.case_type_name' in 'field list']"]
  )
  
  **Tags:** civireport
  
  > **Comments:**
  > **username_1**: Would it be worth replicating on dmaster.demo.civicrm.org? Usually a good step before JIRA. Though seems to be non-functioning currently  
  > **username_0**: Have replicated it on Circle Interactive's demo site (https://demo.circle-interactive.co.uk) at least, so it's definitely a whole-CiviCRM issue. Awaiting my account approval to post it on JIRA now. My first bug - how exciting!  
  > **username_1**: Cool. Add the JIRA link as an Answer when you get it, then you can update that answer when it gets a fix.  
  
  ---
  
  ## 0 answers
  
  