Distinct count of COLUMN1 for each value in COLUMN2

Hi Guys,

I am trying to convert the below query to a!queryEntity()

SQL: SELECT COUNT(DISTINCT `COLUMN1`),`COLUMN2` FROM `TABEL ` WHERE ` COLUMN2` IN (id1,id2) GROUP BY ` COLUMN2 `

I want distinct count of COLUMN1 for each value in from COLUMN2

I have written the below logic in appian

     aggregation: a!queryAggregation(

        {

          a!queryAggregationColumn(

            field: " COLUMN1",

            aggregationFunction: "COUNT",

             isGrouping :true()

          ) ,

            a!queryAggregationColumn(

            field: " COLUMN2",

             isGrouping :true()

          )

        }

      )

It is working fine for one ID, But not getting desired output when i pass multiple ID 

Can someone please help, Thank You:)

Regards,

Shashank

  Discussion posts and replies are publicly visible

Parents
  • Please replace by the below code,

    local!data: a!queryEntity(
    entity: consToDatabaseEntity,
    query: a!query(

    aggregation: a!queryAggregation(
    {
    a!queryAggregationColumn(
    field: "manufacturerId",
    isGrouping: true
    ),
    a!queryAggregationColumn(
    field: "deviceId",
    isGrouping: true,
    aggregationFunction:"COUNT"
    )
    }
    ),
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: if(
    rule!APN_isEmpty(
    ri!manufacturerId
    ),
    {},
    {
    a!queryFilter(
    field: "manufacturerId",
    operator: "IN",
    value: ri!manufacturerId
    ),

    }
    )
    ),
    pagingInfo: local!pagingInfo
    )
    )

    Please let me know if its worked for you,

    Thanks
    Aditya
Reply
  • Please replace by the below code,

    local!data: a!queryEntity(
    entity: consToDatabaseEntity,
    query: a!query(

    aggregation: a!queryAggregation(
    {
    a!queryAggregationColumn(
    field: "manufacturerId",
    isGrouping: true
    ),
    a!queryAggregationColumn(
    field: "deviceId",
    isGrouping: true,
    aggregationFunction:"COUNT"
    )
    }
    ),
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: if(
    rule!APN_isEmpty(
    ri!manufacturerId
    ),
    {},
    {
    a!queryFilter(
    field: "manufacturerId",
    operator: "IN",
    value: ri!manufacturerId
    ),

    }
    )
    ),
    pagingInfo: local!pagingInfo
    )
    )

    Please let me know if its worked for you,

    Thanks
    Aditya
Children