title: Aggregate queries in Laravel Query Builder with group by
body: <p>I have a table birds.</p>
  <p>I want to count each kind of birds in a single query.</p>
  <p>I want to combine these queries into a single query in Eloquent if possible.</p>
  <pre><code> select count(id) as count1 from birds where kind = a;
  
   select count(id) as count2 from birds where kind = b;
  
   select count(id) as count2 from birds where kind = c;
  </code></pre>
  <p>I tried something like</p>
  <pre><code>$first = DB::table('birds')-&gt;selectRaw('count(id) as count1')-&gt;where('kind','a');
  DB::table('birds')-&gt;selectRaw('count(id) as count2')-&gt;where('kind','b')-&gt;unionAll($first)-&gt;get();
  </code></pre>
  <p>i don't think union is giving me what i want.</p>
  <p>i just need something like</p>
  <pre><code>DB::raw(' (select count(id) from birds where kind = a) as count1 ', ' (select count(id)  from  birds where kind = a) as count2  ', ' (select count(id) from birds where kind = a) as count3 ')
  </code></pre>
  <p>i want to combine the queries</p>
  <p>like</p>
  <pre><code>Select ( select count(id)  from birds where kind = 'a') as count1, ( select count(id)  from birds where kind = 'b') as count2,  ( select count(id)  from birds where kind ='c') as count3 from birds ;
  </code></pre>
  <p>. please give me a tip how to achieve it.</p>