first(T.A : ‘a) sort 🡒 ‘a, aggregator

The aggregator requires a sort option to be specified and returns the first value for each group.


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
    first(T.A) sort T.A
    group by gdim

The sort option can be applied to any ordered data type. When the group is empty, the default value for the data type is used.

See also