first

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

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

Example:

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
    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