Skip to content
Maxim Stupakov edited this page May 28, 2018 · 1 revision

Calculates the average value of a numeric column.

$sloth = Sloth::from($data)
    ->group('foo', 'baz')
    ->avg();
$sloth->print();
foo     baz
one     2
two     5.5
print_r($sloth->fetch());
Array
(
    [0] => Array
    (
        [foo] => one
        [baz] => 2
    )
    [1] => Array
    (
        [foo] => two
        [baz] => 5.5
    )
)
Clone this wiki locally