Group By in Yii2
In Yii framework we can use GroupBy Just like we do in raw sql statements.You can define column name in group by and you can set multiple columns in array.For example below:
$model = (new \yii\db\Query())
->select(['col_1','col_2','col_3'])
->from('tableName')
->groupBy('col_name')
->having('id < 8')
->all();
print_r($model);