on 10-17-2018 7:20 PM
Hello Data Service experts,
In HANA, there is a DENSE RANK and STRING AGG function.
I am trying to accomplish what these functions do in Data Services, but I am not able to find similar functions.
Here is what the 2 functions do:
Ex.
CUST | ORDER #
John | 1
John | 2
John | 5
John | 7
John | 11
If I do a STRING_AGG() over partition CUST, ordered by ORDER desc, I will get:
CUST | STRING_AGG
John | 1, 2, 5, 7, 11
Ex. TABLE:
CUST | PRODUCT | PURCHASE
John | A | $500
John | A | $1000
John | B | $2500
John | B | $1300
John | B | $7000
John | C | $5000
If i do a DENSE_RANK() over partition CUST & PRODUCT, ordered by PURCHASE descending, my outcome would be:
CUST | PRODUCT | PURCHASE | DENSE_RANK
John | A | $500 | 1
John | A | $1000 | 2
John | B | $2500 | 2
John | B | $1300 | 3
John | B | $7000 | 1
John | C | $5000 | 1
Thanks!
If you know the maximum of records per partition, you can use a Reverse_Pivot transform and then concatenate all your result columns together.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
For the string_agg() you've to write a custom function in BODS.
For dense_rank() you can go with gen_row_num_by_group() function in BODS.
Let us know if you need more assistance.
Thanks,
Rajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.