Answers.Body: <p>It's a bug in the report but you can work around it by turning off ONLY_FULL_GROUP_BY on the server. See <a href="https://docs.civicrm.org/sysadmin/en/latest/requirements/#mysql-configuration" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/requirements/#mysql-configuration</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T12:50:16.170Z
Answers.Text: Thanks! It works, but only partially - I am still not able to sort the report by the age of the participants (I can show the column "Age", but in sorting options, I have a choice called "Sort by Age in the day of the event" (not "Age"). Here is the error I'm getting:
  
  `#6 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "1054 ** Unknown column 'contact_civireport.age_at_event' in 'field list'")`
Answers.UserDisplayName: pannga
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T13:04:10.160Z
Answers.Text: Ah yet another bug! Can you file a report at https://lab.civicrm.org/dev/report/issues?
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T13:16:36.283Z
Answers.Text: Already done that, thanks! https://lab.civicrm.org/dev/report/issues/26
Answers.UserDisplayName: pannga
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T12:39:07.617Z
Answers.LastActivityDate: 2020-02-27T12:39:07.617Z
Answers.UserDisplayName: Demerit
Body: <p>when I'm preparing a report (Event Participants) through CiviCRM Report module and I want to sort the results by anything (age, name, etc) I am getting a fatal error: <code>DB ERROR: No such field</code></p>
  
  <p>I'm currently on <strong>Drupal 7.69</strong> and <strong>CiviCRM 5.20.</strong></p>
  
  <p>Here is the full log of this issue:</p>
  
  <pre><code>     [debug] $backTrace = #0 /var/www/html/sites/all/modules/civicrm/CRM/Core/Error.php(208): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
  #2 /var/www/html/sites/all/modules/civicrm/packages/DB.php(987): PEAR_Error-&gt;__construct("DB Error: unknown error", -1, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #3 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error-&gt;__construct(-1, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #4 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "DB_Error", TRUE)
  #5 /var/www/html/sites/all/modules/civicrm/packages/DB/common.php(1920): PEAR-&gt;__call("raiseError", (Array:7))
  #6 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common-&gt;raiseError(-1, NULL, NULL, "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "1055 ** Expression #21 of SELECT list is not in GROUP BY clause and contains ...")
  #7 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli-&gt;mysqliRaiseError()
  #8 /var/www/html/sites/all/modules/civicrm/packages/DB/common.php(1229): DB_mysqli-&gt;simpleQuery("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #9 /var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php(2416): DB_common-&gt;query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #10 /var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php(1607): DB_DataObject-&gt;_query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #11 /var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php(435): DB_DataObject-&gt;query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #12 /var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php(1428): CRM_Core_DAO-&gt;query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", TRUE)
  #13 /var/www/html/sites/all/modules/civicrm/CRM/Report/Form.php(3076): CRM_Core_DAO::executeQuery("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #14 /var/www/html/sites/all/modules/civicrm/CRM/Report/Form.php(3561): CRM_Report_Form-&gt;buildRows("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", (Array:0))
  #15 /var/www/html/sites/all/modules/civicrm/CRM/Report/Form/Event/ParticipantListing.php(616): CRM_Report_Form-&gt;postProcess()
  #16 /var/www/html/sites/all/modules/civicrm/CRM/Core/Form.php(495): CRM_Report_Form_Event_ParticipantListing-&gt;postProcess()
  #17 /var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Submit.php(74): CRM_Core_Form-&gt;mainProcess()
  #18 /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Submit-&gt;perform(Object(CRM_Report_Form_Event_ParticipantListing), "submit")
  #19 /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Report_Form_Event_ParticipantListing), "submit")
  #20 /var/www/html/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page-&gt;handle("submit")
  #21 /var/www/html/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(114): CRM_Core_Controller-&gt;run()
  #22 /var/www/html/sites/all/modules/civicrm/CRM/Report/Page/Instance.php(90): CRM_Utils_Wrapper-&gt;run("CRM_Report_Form_Event_ParticipantListing", NULL, (Array:0))
  #23 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Report_Page_Instance-&gt;run((Array:4), NULL)
  #24 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:14))
  #25 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
  #26 /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:4))
  #27 /var/www/html/includes/menu.inc(527): civicrm_invoke("report", "instance", "26")
  #28 /var/www/html/index.php(21): menu_execute_active_handler()
  #29 {main}
  </code></pre>
  
  <p>Has anyone come across such an issue? Is my database missing a table header?</p>
  
Tags: <civireport><error><database>
Title: CiviCRM Report - Sorting DB error
ThreadText: # CiviCRM Report - Sorting DB error
  
  (Asked by: username_0 on 2020-02-27)
  
  when I'm preparing a report (Event Participants) through CiviCRM Report module and I want to sort the results by anything (age, name, etc) I am getting a fatal error: DB ERROR: No such field
  I'm currently on Drupal 7.69 and CiviCRM 5.20.
  Here is the full log of this issue:
       [debug] $backTrace = #0 /var/www/html/sites/all/modules/civicrm/CRM/Core/Error.php(208): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
  #2 /var/www/html/sites/all/modules/civicrm/packages/DB.php(987): PEAR_Error->__construct("DB Error: unknown error", -1, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #3 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-1, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #4 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "DB_Error", TRUE)
  #5 /var/www/html/sites/all/modules/civicrm/packages/DB/common.php(1920): PEAR->__call("raiseError", (Array:7))
  #6 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-1, NULL, NULL, "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "1055 ** Expression #21 of SELECT list is not in GROUP BY clause and contains ...")
  #7 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
  #8 /var/www/html/sites/all/modules/civicrm/packages/DB/common.php(1229): DB_mysqli->simpleQuery("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #9 /var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php(2416): DB_common->query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #10 /var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php(1607): DB_DataObject->_query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #11 /var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php(435): DB_DataObject->query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #12 /var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php(1428): CRM_Core_DAO->query("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", TRUE)
  #13 /var/www/html/sites/all/modules/civicrm/CRM/Report/Form.php(3076): CRM_Core_DAO::executeQuery("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...")
  #14 /var/www/html/sites/all/modules/civicrm/CRM/Report/Form.php(3561): CRM_Report_Form->buildRows("SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", (Array:0))
  #15 /var/www/html/sites/all/modules/civicrm/CRM/Report/Form/Event/ParticipantListing.php(616): CRM_Report_Form->postProcess()
  #16 /var/www/html/sites/all/modules/civicrm/CRM/Core/Form.php(495): CRM_Report_Form_Event_ParticipantListing->postProcess()
  #17 /var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Submit.php(74): CRM_Core_Form->mainProcess()
  #18 /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Submit->perform(Object(CRM_Report_Form_Event_ParticipantListing), "submit")
  #19 /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Report_Form_Event_ParticipantListing), "submit")
  #20 /var/www/html/sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("submit")
  #21 /var/www/html/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(114): CRM_Core_Controller->run()
  #22 /var/www/html/sites/all/modules/civicrm/CRM/Report/Page/Instance.php(90): CRM_Utils_Wrapper->run("CRM_Report_Form_Event_ParticipantListing", NULL, (Array:0))
  #23 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Report_Page_Instance->run((Array:4), NULL)
  #24 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:14))
  #25 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
  #26 /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:4))
  #27 /var/www/html/includes/menu.inc(527): civicrm_invoke("report", "instance", "26")
  #28 /var/www/html/index.php(21): menu_execute_active_handler()
  #29 {main}
  
  Has anyone come across such an issue? Is my database missing a table header?
  
  **Tags:** civireport, error, database
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-02-27. Score: 1 | Accepted answer
  
  It's a bug in the report but you can work around it by turning off ONLY\_FULL\_GROUP\_BY on the server. See <https://docs.civicrm.org/sysadmin/en/latest/requirements/#mysql-configuration>
  
  > **Comments:**
  > **username_0**: Thanks! It works, but only partially - I am still not able to sort the report by the age of the participants (I can show the column "Age", but in sorting options, I have a choice called "Sort by Age in the day of the event" (not "Age"). Here is the error I'm getting:  `#6 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-19, NULL, NULL, "SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_so...", "1054 ** Unknown column 'contact_civireport.age_at_event' in 'field list'")`  
  > **username_1**: Ah yet another bug! Can you file a report at https://lab.civicrm.org/dev/report/issues?  
  > **username_0**: Already done that, thanks! https://lab.civicrm.org/dev/report/issues/26  
  
  ---
  
  