Skip to main content
Participating Frequently
May 17, 2023
Question

Query expression

  • May 17, 2023
  • 2 replies
  • 0 views

I want to the same result as this SQL query "SELECT WorkType, COUNT(DISTINCT Site) AS DistinctSites FROM your_table_name GROUP BY WorkType;" in using query on data entity. I am able to get the count of sites and Group by WorkType but count of sites is not distinct.

a!queryEntity(
  entity: cons!SD_TEST_DATA,
  query: a!query(
    aggregation: a!queryAggregation(
      aggregationColumns: {
        a!queryAggregationColumn(
          field: "worktype",
          isGrouping: true
        ),
        a!queryAggregationColumn(
          field: "site",
          alias: "site_count",
          aggregationFunction: "COUNT"
        )
      }
    ),    
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: 50
    )
  ),
  fetchTotalCount: false
)

    2 replies

    stefanhelzle0001
    Brainy
    May 17, 2023

    Interesting, there is a very similar conversation from yesterday. Maybe that helps.

    community.appian.com/.../generate-report-column-charts-from-expression-rule

    Participating Frequently
    May 17, 2023

    Thank You Stefan