title: count row with total
body: <p>From tbl Department, I am trying to write a stored procedure to display output as shown below where I can find the count from each row based on following conditions:</p>
  
  <ol>
  <li>Total = 100 </li>
  <li>Total >100 and &lt;=200 </li>
  <li>Total >200 and &lt;=300 </li>
  <li><p>Total >300 
  <img src="https://i.stack.imgur.com/8vdlU.png" alt="enter image description here"></p>
  
  <p>set @select = 'select count(*) as Orders, sum (tbl.Expenses) as Total from tbl group by tbl.Department'</p></li>
  </ol>
  
  <p>So, how can I dynamically get the output for 4 conditions as shown above based on my @select statement. </p>