Add the option for DISTINCT count in query

This option would add some power to the query tool, and remove the need for custom coding or SDK work to create a smart query to get the counts we want for various things.
  • Thomas Scarlett
  • Jun 29 2015
  • Reviewed: Voting Open
  • Attach files
  • Thomas Wedge commented
    March 28, 2022 09:50

    Pat, Suppress duplicate rows only suppresses rows after aggregation which means that any counts will be incorrectly multiplied by any duplicate rows in the dataset.

  • Thomas Wedge commented
    September 16, 2021 09:44

    It would also allow for multiple counts on different fields to be done in the same query output as currently adding multiple counts() will only return the same value based on the query logic.

    Counting different fields at the same time would be useful for generating profile reports such as number of Event Registrations, number of Education Involvements etc.

    It will also help to avoid logic errors where the user has an OR statement that has two true values for example if I create a query for Constituent\Gender = Male Or Constituent\Age = 35. Any Male constituents aged 35 will be counted twice if the regular Count() is used, but count(distinct ID) would only count that constituent once.

  • Admin
    Pat Conley commented
    September 15, 2021 17:44

    Thank you for your quick and detailed responses. Setting this back to Open for voting.

  • Ineke Clewer commented
    September 14, 2021 15:47

    yes exactly what Jefferson said, it's when you want to see if someone has maybe only one payment method or multiple, you could do a count distinct on payment method

  • Jefferson Davis commented
    September 14, 2021 14:08

    The DISTINCT count requested in this idea is different than the Suppress duplicate rows. That functionality is SELECT DISTINCT <stuff> FROM <TABLE>. I believe what's being requested is SELECT COUNT(DISTINCT <column>) that returns the number of distinct values in that column. It's a bit of a bad example, but Lookup ID, COUNT(Amount) would return the number of gifts given where Lookup ID, COUNT(DISTINCT Amount) would return the number of different amounts a constituent had given.

  • Admin
    Pat Conley commented
    September 14, 2021 13:47

    There is a check box on the ad-hoc query definition editor’s “Set save options” tab to “Suppress duplicate rows.” This adds a DISTINCT modifier to the SELECT statement

  • +48