Re: Nested GroupBy or for each
One extra question appeared yesterday...
What can I do, when I want to calculate the average result based on at least 3 but max 4 results? In addition I do not have a counting column like above.
Pseudo Code would look like this:
if(number of results is less than 3 within campaign)
then -1
else
if(number of results is bigger than 4 within campaign)
pick only first 4 results
end if
calculate average
end if
For example (almost similar table to the first question):
measurement_campaign, sensor, measurement_result
A, S1, 0.1
A, S1, 0.5
A, S1, 0.4
A, S1, 0.3
A, S1, 0.6
A, S2, 1.1
A, S2, 1.2
A, S2, 1.1
B, S1, 0.5
B, S1, 0.7
B, S1, 0.6
B, S2, 0.4
B, S2, 0.3
B, S2, 0.2
B, S2, 0.8
B, S2, 0.4
The background is, that if I use too much values the weighting of the first results gets less.