title: fetch other(custom) column with group by and count using laravel
body: <p>I want to fetch vacancies from the vacancies table. </p>
  
  <p><strong>vacancies</strong> table</p>
  
  <p><strong>id</strong>  |                     <strong>position</strong> </p>
  
  <p>1 | Laravel dev</p>
  
  <p>2 | Php dev</p>
  
  <p>3 | Laravel dev</p>
  
  <p>4 | Laravel dev</p>
  
  <p>5 | Laravel dev</p>
  
  <p>I want to fetch vacancies using some where statement but result should be with count. </p>
  
  <p><a href="https://i.stack.imgur.com/C3b00.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C3b00.png" alt="enter image description here"></a></p>
  
  <p>As you can see in above screenshot... I am getting only Position column and Count  for this i am using following query- </p>
  
  <pre><code>$vacancies = Vacancy::where('tag_category_id', $TagCatId)
              -&gt;select('position', DB::raw('count(*) as total'))
              -&gt;groupBy('position')
              -&gt;get();
  </code></pre>
  
  <p>What if i want ID column as well in this result?</p>