title: can i run a group by statement within stored procedure and return the output as variable
body: <p>Hi All, 
   i am a nub to mysql and i am experimenting with stored procedure, i have written a script to calculate count of Respondent id, for now stored procedure returns a cumulative number however i would like resultant grouped by each city. when i attempt that i get an error message  stating "Result consisted of more than one row error"</p>
  
  <p>Note: i am aware that i can query using where statement for each city however that method is in-efficient as i have to manually key in each distinct city name hence i am looking for alternatives to efficiently tackle this </p>
  
  <p>any help would be greatly appreciated </p>
  
  <p>regards
  Sri</p>
  
  <h2>Stored Procedure code</h2>
  
  <pre><code>DROP PROCEDURE IF EXISTS `Total_grpby`$$
  CREATE DEFINER=`root`@`localhost` PROCEDURE
   `total_grpby
  `(
  OUT ex_total INT 
  )
  
  BEGIN
  SELECT COUNT(rsp_id) As total INTO ex_total
   FROM test.`jnk_test`
   GROUP BY Dmc_Cty;
  END$$
  </code></pre>
  
  <h2>desired output</h2>
  
  <pre><code>dmc_cty    Total
  Chennai    337
  Delhi      263
  Gurgaon    53
  Hyderabad  406
  Mumbai     482
  Noida      464
  Pune       522
  </code></pre>