on 09-06-2012 6:58 AM
Hi Folks,
I would like to use one of the aggregation functions FIRST(), LAST() in my script but unfortunately they are not supported in HANA. Do you guys have any work around to select the first value of the right the table in a join? The scenario as below -
Table 1
Customer Name |
---|
C1 |
C2 |
Table 2
Customer | Parameter 1 | Value |
---|---|---|
C1 | P1 | 10 |
C1 | P2 | 15 |
Preferred Output
Customer | Value |
---|---|
C1 | 10 |
C2 |
/bikas
Hi Bikas,
Couple of thoughts:
a. Have you tried creating a calculated measure and within there selected the aggregation as max & min instead of sum? You might have to also check "Calculate before aggregation"
b. May be a scripted calculation view that does SELECT TOP 1 on the field with the join of the tables with "ORDER BY <VALUE_FIELD>" . For getting last, you could use the same SELECT TOP 1 but then also use "ORDER BY <VALUE_FIELD> DESC".
Thanks,
Anooj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anooj,
Thanks for your thoughts.
a. I can do min() and max() very well. But here I would like to pick the first value.
b. select top 1 will give me 1 row as output but as you can see, my preferred output is more than 1 rows.
I am trying to find a work around using counter function in the calc view where I can filter where counter = 1.
Keen to hear some more thoughts.
/bikas
Left outer join.. . We are getting into more of trial and error mode as I haven't tried this personally yet.
If you have a requirement that the first value should be available for each customer (C1, C2, C3.. etc), then this model will not work. In that case, you'll have to define what is the "first" record mean. Does it mean the min(value) or max(value) because in case of relational database order of rows do not matter much.
I am not sure if there are pseudo columns like ROWID available in HANA, but as Varada mentioned, it is worth the try.
Regards,
Ravi
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.