title: Yii2 filter Sum data in GridView
body: <p>I'm trying display and filter data which I got via SQL SUM operator.
  I have 2 table employee and department. Table employee contains department_id filed and salary filed. I need display all department and total SUM salary for every department.
  I followed this <a href="http://www.yiiframework.com/wiki/679/filter-sort-by-summary-data-in-gridview-yii-2-0/" rel="nofollow noreferrer">guide</a>, but GridView does not  display any data.
  Here is action:</p>
  <pre><code>public function actionIndex()
  {
      $searchModel = new DepartmentFrontendSearch();
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
      return $this-&gt;render('index',
          [
              'dataProvider' =&gt; $dataProvider,
              'searchModel' =&gt; $searchModel,
  
          ]
      );
  }
  </code></pre>
  <p>Model:</p>
  <pre><code>class DepartmentFrontendSearch extends DepartmentFrontend
  
  public $employee_count;
  public $salary;
  
  
  public function rules() {
      return [
  
          [['employee_count','salary','name'], 'safe']
      ];
  }
  
  public function search($params) {
  
      $query = DepartmentFrontend::find();
      $subQuery = Employee::find()
          -&gt;select('department_id, SUM(salary) as salary_amount')
          -&gt;groupBy('department_id');
      $query-&gt;leftJoin(['salarySum' =&gt; $subQuery], 'salarySum.department_id = id');
  
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
      ]);
      $dataProvider-&gt;setSort([
          'attributes' =&gt; [
              'name',
              'salary'
          ]
      ]);
  
      $this-&gt;load($params);
  
      if (!$this-&gt;validate()) {
          return $dataProvider;
      }
  
      $query-&gt;andFilterWhere(['like', 'name', $this-&gt;name]);
      $query-&gt;andWhere(['salarySum.salary_amount' =&gt; $this-&gt;salary]);
      return $dataProvider;
  }
  </code></pre>
  <p>GRID:</p>
  <pre><code>   echo GridView::widget([
     'dataProvider' =&gt; $dataProvider,
     'filterModel' =&gt; $searchModel,
     'columns' =&gt; [
         ['class' =&gt; 'yii\grid\SerialColumn'],
         'salary_amount',
         'employee_count',
         'name',
  
     ],
  </code></pre>
  <p>]);</p>
  <p>So, can anybody tell me what I did wrong?</p>