g_lstpkg(G;S;O;X)
Returns a list value for each group, in the specified order. (Available as of version 15.21)
Function type
Vector only
Syntax
g_lstpkg(G;S;O;X)
Input
| Argument | Type | Description |
|---|---|---|
G |
any | A space- or comma-separated list of column names Rows are in the same group
if their values for all of the columns listed in If If any of the columns listed in |
S |
integer | The name of a column in which every row evaluates to a 1 or 0, which determines
whether or not that row is selected to be included in the calculation If
If any of the values in
|
O |
integer | A space- or comma-separated list of column names that
determine the row order within a particular group If
If any of the values in |
X |
package | The X argument must be a package value |
Return Value
For every row in each group defined by G and ordered by O (and
for those rows where S=1, if
specified), g_lstpkg returns a list value for each
group specified by G for the package
X.
g_lstpkg(G;S;O;X) works like g_lst(G;S;O;X), except that
X must be a package, and
g_lstpkg returns a transposed
version of what g_lst returns.Example
In the following example, we use r_mappkg(C;S;X) to
create a package out of each row of table data in
pub.demo.retail.item. Then, we use
g_lstpkg(G;S;O;X) to return a list of items
grouped by transaction ID. Finally, we convert that list of records
(objects) into JSON format.

record column and use
r_mappkg(C;S;X) to create a package value
for each row in the
table:<willbe name="record" value="r_mappkg(;;rcv_)"/>Then, we create a group column and use
g_lstpkg(G;S;O;X) to create a list out of
the package in the record column, grouped by
transid:
<willbe name="group" value="g_lstpkg(transid;;;record)"/>
<sel value="g_first1(transid;;)"/>Then, we can use enjson(V;O) to convert the list in the
group column into JSON:
<willbe name="json" value="enjson(group;)"/>
<colord cols="transid,json"/>
If you display the full details of the json column, you
will see a JSON representation of a package of equal-length lists,
with each key corresponding to the values from the same key in the
package arguments.
