Skip to Content

Duplicates Issue with Aggregation in HANA Calculation view

Hi Experts,

I have a below requirement, kindly help me to fix this.

Col A Col B

SAP ABAP
SAP ABAP
SAP SD
SAP HANA

when I use aggregation for the above table and make column B as aggregated column and aggregated type as "COUNT" am getting count value as 4 for SAP.

It providing me the total row count for SAP in the output. where as the expected count value should be "3". Since row 1 and 2 are duplicates.

Can someone help me, how to achieve the Count value as "3" for SAP in Output.

Thanks
Rufus Samuel

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Aug 12, 2017 at 08:54 AM

    You can do an aggregation before the aggregation you describe. The additional aggregation just needs both fields (as "normal" fields, not as aggregated ones) to eliminate duplicates.

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 16, 2017 at 04:33 AM

    please refer below

    This is my table

    Thanks,

    Shanthi.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 16, 2017 at 04:36 AM
    SELECT  COUNT(DISTINCT(row_2)) FROM <SCHEMA>.TABLE
    Add comment
    10|10000 characters needed characters exceeded

    • This SQL is correct, but the brackets after DISTINCT are unnecessary.

      DISTINCT is not a function and the brackets don't define what part of the count should be worked on by the DISTINCT.