title: Laravel - Column not found: 1054 Unknown column in Laravel Query
body: <p>I tried to run a Laravel query that selects a particular field that appears more than once, and I got the error below.</p>
  
  <blockquote>
    <p>"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'no_of_service' in 'having clause' (SQL: select count(*) as aggregate from <code>cloudsubscriptions</code> inner join <code>service_package</code> on <code>cloudsubscriptions</code>.<code>package_id</code> = <code>service_package</code>.<code>id</code> group by <code>cloudsubscriptions</code>.<code>msisdn</code>, <code>service_package</code>.<code>title</code> having <code>no_of_service</code> > 1) </p>
  </blockquote>
  
  <pre class="lang-php prettyprint-override"><code>$subscribers = Cloudsubscriptions::join("service_package", 
      "cloudsubscriptions.package_id", "=", "service_package.id")
      -&gt;select("cloudsubscriptions.msisdn", "cloudsubscriptions.service_name", 
          "service_package.title",
          DB::raw("COUNT(cloudsubscriptions.msisdn) as 'no_of_service'"))
      -&gt;groupBy("cloudsubscriptions.msisdn", "service_package.title")
      -&gt;having('no_of_service', '&gt;', 1)
      -&gt;get();
  </code></pre>
  
  <p>I expect to see fields that appear more than once.</p>