Skip to Content
0

Duplicates Issue with Aggregation in HANA Calculation view

Aug 12, 2017 at 07:31 AM

263

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Florian Pfeffer
Aug 12, 2017 at 08:54 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Shanthi Bhaskar Aug 16, 2017 at 04:33 AM
0

please refer below

This is my table

Thanks,

Shanthi.

Share
10 |10000 characters needed characters left characters exceeded
Shanthi Bhaskar Aug 16, 2017 at 04:36 AM
0
SELECT  COUNT(DISTINCT(row_2)) FROM <SCHEMA>.TABLE
Show 1 Share
10 |10000 characters needed characters left 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.

0