title: Column not found on COUNT LEFT JOIN
body: <p>i'm trying to search user with join introducing company, and count total topup transaction with the following code</p>
  
  <pre><code>$data = Yii::app()-&gt;db-&gt;createCommand()-&gt;select('a.Id, a.UserName, a.Name, a.Sex, a.DOB, a.Email, a.ContactNo, a.Credit, a.EmailVerified, a.Level, a.CreatedTime, a.Active, a.Referral, a.ReceivedFirstTimeDepositBonus, b.Name AS ReferralName, COUNT(c.Id) AS TransactionCount')-&gt;from('user a')-&gt;leftJoin('company b', 'a.Referral=b.Id')-&gt;leftjoin('transaction c', 'a.Id = c.UserId')-&gt;group('a.Id');
  
  $data = $data-&gt;andWhere('a.Role = 0');
  $data = $data-&gt;andWhere('c.TransactionCount &gt; 0');
  $data = $data-&gt;queryAll();
  </code></pre>
  
  <p>but yii throw me error like this</p>
  
  <blockquote>
    <p>Column not found: 1054 Unknown column 'c.TransactionCount' in 'where
    clause'. The SQL statement executed was: SELECT a.Id, a.UserName,
    a.Name, a.Sex, a.DOB, a.Email, a.ContactNo, a.Credit, a.EmailVerified,
    a.Level, a.CreatedTime, a.Active, a.Referral,
    a.ReceivedFirstTimeDepositBonus, b.Name AS ReferralName, COUNT(c.Id)
    AS TransactionCount FROM <code>user</code> <code>a</code> LEFT JOIN <code>company</code> <code>b</code> ON
    a.Referral=b.Id LEFT JOIN <code>transaction</code> <code>c</code> ON a.Id = c.UserId WHERE
    (a.Role = 0) AND (c.TransactionCount > 0) GROUP BY <code>a</code>.<code>Id</code> ORDER BY
    <code>Id</code> LIMIT 20</p>
  </blockquote>
  
  <p>and i try to look at the query for long time, but i cant see what is the problem i don't know why it will throw me error ,even i try</p>
  
  <pre><code>$data = $data-&gt;andWhere('TransactionCount &gt; 0');
  </code></pre>
  
  <p>but get the same error just column name differrent</p>