title: laravel: error: using join, raw and having in query
body: <p>I use laravel framework.  I wrote this query but  it shows me an error:</p>
  
  <p>Error:</p>
  
  <pre><code>SQLSTATE[42S22]: Column not found: 1054 Unknown column 'schools.grade' in 'field list' (SQL: select `students`.`name`, `students`.`lastname`, students.id, max(`schools.grade`) as `grade` from `students` inner join `schools` on `schools`.`id` = `students`.`id` group by `schools`.`id` having `grade` = 6)
  </code></pre>
  
  <p>my code:</p>
  
  <pre><code>$stu = students::join('schools', 'schools.id',"=", 'students.id')
              -&gt;select('students.name','students.lastname',DB::raw('students.id, max(`schools.grade`) as `grade`'))
              -&gt;groupBy('schools.id')
              -&gt;having('grade','=',$grade)
              -&gt;get();
          dd($stu);
  </code></pre>
  
  <p>what's wrong?
  thx</p>