Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
Sorry for the confusing title, I think an example will makes things a little easier.
Let's say I have this table:
Customer | Day | Sales |
---|---|---|
A | 1 | 20 |
B | 2 | 30 |
C | 3 | 15 |
A | 4 | 25 |
B | 5 | 35 |
And now I add the the aggreggation of the sum sales based on customer (syntaxis might be wrong, doing it from memory) aggr(sum(sales),Customer), that leaes me with the following table:
Customer | Day | Sales | Aggr |
---|---|---|---|
A | 1 | 20 | 45 |
B | 2 | 30 | 65 |
C | 3 | 15 | 15 |
A | 4 | 25 | - |
B | 5 | 35 | - |
So as you can see, when aggregating my table puts the value only in the first Customer it finds(or I don't know the logic behind), if I wanted to do something like a new column Sales/Aggr the output would be the following one:
Customer | Day | Sales | Aggr | Ratio |
---|---|---|---|---|
A | 1 | 20 | 45 | 0.44 |
B | 2 | 30 | 65 | 0.46 |
C | 3 | 15 | 15 | 1 |
A | 4 | 25 | - | - |
B | 5 | 35 | - | - |
So some columns won't calculated... Ideally what I would like is to have the aggregation of the sum repeated on each value 'Customer' that corresponds to.
Thank you!
You need a NODISTINCT within aggr(), like:
aggr( NODISTINCT sum(sales),Customer)
Hi,
You are almost there just use sum() before your aggr()
like sum(aggr(sum(sales),Customer))
Regards,
Prashant
You need a NODISTINCT within aggr(), like:
aggr( NODISTINCT sum(sales),Customer)
This worked!
Thank you very much .