ArticleController :
$discussedArticle = Articles::find()->with('comments')->groupBy('article_id')->orderBy('count(article_id) DESC')->asArray()->all();
Model : article
public function getComments()
{
return $this->hasMany(Comments::className(), ['article_id' => 'id']);
}