table T = with
[| as Group, as Value |]
[| "A", 1 |]
[| "A", 2 |]
[| "A", 9 |]
[| "B", 4 |]
[| "B", 5 |]
table G[g] = by T.Group
G.Median = median(T.Value)
show table "Median" with
g as "Group"
G.Median as "Median"
This produces the following table:
Group
Median
A
2
B
4.5
Remarks
Empty groups return the default value for the data type.