I found this in the manual, but have no idea how to implement the same
yii\db\Query::count(); returns the result of a COUNT request. Other similar methods include sum($q) , average($q) , max($q) , min($q) , which support the so-called aggregated data query. $q parameter is required for these methods and can be either a column name or an expression.
Say, for example, I have a table name of 'billing' with columns:
name amount charge1 110.00 charge2 510.00 Total - 620.00
How i use
yii\db\Query::sum('amount');
I also tried how
$command = Yii::$app->db->createCommand("SELECT sum(amount) FROM billing"); yii\db\Query::sum($command);
but the page generates an error.
Thanks.
yii2
Joshi
source share