Title: Filtering query with SUM
Last modified: August 22, 2016

---

# Filtering query with SUM

 *  Resolved [madrugadora](https://wordpress.org/support/users/madrugadora/)
 * (@madrugadora)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/filtering-query-with-sum/)
 * Hello,
 * I have a query with details of user registration and payment details to an event,
   and I need to get the sum of the payment amounts, but filtering by different 
   columns (nationality, age, etc.) I would like the user to do the filtering directly
   on the report.
 * Is there any way to have the SUM query, and do the grouping depending on the 
   filters? I guess if it can be done it has to do with the “related group by” on
   the custom fields, but I don’t know how to use it.
 * Thank you in advance and regards,
 * María.
 * [https://wordpress.org/plugins/exports-and-reports/](https://wordpress.org/plugins/exports-and-reports/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/filtering-query-with-sum/#post-5911942)
 * You can use subqueries in the SELECT to get a SUM from a separate set, but just
   be sure to use the placeholders as described in the Query textarea description.
 * If you are looking to show a SUM of all of the data on the current page, that’s
   something I’ve looked into and it won’t be available in this plugin any time 
   soon, it’s a very tricky feature that’s taken a bit more time and thought than
   I have to finish it.
 * We don’t have custom grouping by filters, that’s definitely not possible in any
   other way currently, unless you filter the query yourself and try and inject 
   your own filtering.
 * You can filter the options in Exports and Reports 0.6.4 with the new filter `
   exports_reports_report_options` which you will want to override the `$options['
   sql']` with whatever you want. You can probably create your own “placeholder”
   in that part of the query like %%MY_CUSTOM_PLACEHOLDER%% and just replace it 
   in your filtering.

Viewing 1 replies (of 1 total)

The topic ‘Filtering query with SUM’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/exports-and-reports.svg)
 * [Exports and Reports](https://wordpress.org/plugins/exports-and-reports/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/exports-and-reports/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/exports-and-reports/)
 * [Active Topics](https://wordpress.org/support/plugin/exports-and-reports/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/exports-and-reports/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/exports-and-reports/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [grouping](https://wordpress.org/support/topic-tag/grouping/)
 * [sum](https://wordpress.org/support/topic-tag/sum/)

 * 1 reply
 * 2 participants
 * Last reply from: [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/filtering-query-with-sum/#post-5911942)
 * Status: resolved