Group Process
This example shows the usage of Group process
item | cost |
Accessories |
$3,000 |
Human Resource |
$20,000 |
Material |
$50,000 |
Machine |
$30,000 |
Accessories |
$5,000 |
Machine |
$10,000 |
Material |
$20,000 |
->pipe(new Group(array(
"by"=>"item",
"sum"=>"cost",
)))
item | cost |
Accessories |
$8,000 |
Human Resource |
$20,000 |
Machine |
$40,000 |
Material |
$70,000 |
The example demonstrates usage of `Group` process. The group process is used to group row of data and do aggregation calculation.
__Other methods__
Beside `"sum"` aggregation, the group process also support other methods: `"avg"`,`"min"`, `"max"`, `"min"`, `"first"`, `"last"`.
For example:
```
->pipe(new Group(array(
"by"=>"item",
"avg"=>"cost"
)))
```
__By list of fields__
The Group process can group not only by a field but also by multiple fields:
```
->pipe(new Group(array(
"by"=>array("category","line")
"sum"=>"amount"
)))
```