whichever(T.A : ‘a) : ‘b 🡒 ‘a, aggregator
The aggregator returns one value for each group if the group is not empty.
table T = with [| as A, as B |] [| "hello", "a" |] [| "hello", "a" |] [| "hello", "b" |] [| "world", "b" |] [| "world", "c" |] table G[gdim] = by T.B where T.B != "c" show table "" a1b4 with gdim whichever(T.A) group by gdim
When the group is empty, the default value for the data type is used.
The result of the
whichever aggregator is deterministic - i.e. running the script twice over the same data yields the same result - but the ordering of the data cannot be relied upon. This aggregator is intended as a faster alternative to the use of
last without introducing an ordering when it is not needed.