title: how to combine queries yii2
body: <p>I have a query with 2 tables. I want to combine these two queries into one query. how do?</p>
  
  <pre><code>public function actionGroup()
  {
      $query1 = (new \yii\db\Query())
                  -&gt;select(['lao',new \yii\db\Expression('COUNT(lao)'),'nama_ptgs', new \yii\db\Expression('SUM(outstanding)')])
                  -&gt;from('debitur')
                  -&gt;groupBy('lao')
                  -&gt;all();
  
      $query2 = (new \yii\db\Query())
                  -&gt;select(['lao', new \yii\db\Expression('SUM(tgt_pergeseran)')])
                  -&gt;from('resume')
                  -&gt;groupBy('lao')
                  -&gt;all();
  
      return $this-&gt;render('outstanding', [
          'query1' =&gt; $query1,
          'query2' =&gt; $query2,
      ]);
  }
  </code></pre>
  
  <p>example <a href="https://i.stack.imgur.com/WYTi9.png" rel="nofollow noreferrer">sql</a></p>
  
  <pre><code>SELECT debitur.lao, debitur.Outstanding, debitur.jumlah, resume.Target FROM ( SELECT lao, SUM(outstanding) as Outstanding, COUNT(lao) as jumlah FROM debitur GROUP BY lao )debitur INNER JOIN ( SELECT lao, SUM(tgt_pergeseran) as Target FROM resume GROUP BY lao ) resume ON debitur.lao = resume.lao
  </code></pre>
  
  <p>error <a href="https://i.stack.imgur.com/s2y1H.png" rel="nofollow noreferrer">undefined index</a></p>
  
  <p>print($query);
  <a href="https://i.stack.imgur.com/UmDZA.png" rel="nofollow noreferrer">result</a></p>