ActiveRecord query with sum() function

I want query with sum() and groupby function by using the ActiveRecord, my code is as following




$rows = \app\models\MyModel::find()->select(['total'=>'SUM(money)','user_id'])->groupBy('user_id')->all();



and I just get a row with ‘user_id’ attribute, the ‘total’ attribute just gone. and solved by using following code




$rows = \app\models\MyModel::find()->select(['total'=>'SUM(money)','user_id'])->groupBy('user_id')->createCommand()->queryAll();



Did I misunderstanding the usage of ActiveRecord or does this is the right way to get the sum() attribute?