ARB
selects an arbitrary but consistent value from the set of values in a field.
ARB
function is:
ARB(<attribute>)
where attribute is a single-assign attribute or a set (multi-assign attribute).ARB
works as follows:
ARB
first discards all NULL values and then selects an arbitrary but consistent value from the remaining non-NULL values. If the attribute has no non-NULL values, then NULL is returned.ARB
looks at all of the rows in the group (including those with empty sets) and selects the set value from one of the rows. In other words, empty sets and non-empty sets are treated equally. This means that because the selection is arbitrary, the returned set value could be an empty set. The ARB
return type is the same as its argument type: if attribute x is an mdex:long-set
, then so is ARB(x). If the attribute has no non-NULL values, then the empty set is returned.ARB examples
RETURN results AS SELECT ARB(Price) AS prices FROM WineState GROUP BY WineType ORDER BY WineType
WineType prices -------------------------- | Blanc de Noirs | 16.99 | | Bordeaux: | 21.99 | | Brut | 22.99 | | Chardonnay: | 17.95 | | Merlot: | 25.99 | | Pinot Noir: | 14.99 | | Red: | 9.99 | | White: | 20.99 | | Zinfandel: | | --------------------------
ARB
discarded the two NULL values and returned the 21.99 value.RETURN results AS SELECT ARB(Body) AS bodies FROM WineState GROUP BY WineType ORDER BY WineType
WineType bodies ---------------------------------------- | Blanc de Noirs | { Firm, Robust } | | Bordeaux: | { Silky, Tannins } | | Brut | { Robust } | | Chardonnay: | { } | | Merlot: | { } | | Pinot Noir: | { Supple } | | Red: | { Silky, Tannins } | | White: | { } | | Zinfandel: | { Robust, Tannins } | ----------------------------------------