title: mysql query to retrieve count using a single query
body: <p>I have the below result on executing the below query:</p>
  
  <pre><code>select * from db1.user_details;
  
  Dept_Id     Form_Id     Status
  -----------------------------------------------
  dept1       Form1       CD1
  dept1       Form2       CD1
  dept1       Form3       CD2
  dept2       Form1       CD1
  dept3       Form3       CD2
  dept3       Form1       CD1
  dept3       Form2       CD3
  ----------------------------------------------
  </code></pre>
  
  <p>Here CD1 is "received", CD2 is "In Process", CD3 is "Rejected".</p>
  
  <p>Now i want to find out the total no of Received, In Process and Rejected of each dept's</p>
  
  <p>The result should be like:</p>
  
  <pre><code>Dept_Id Received    In Process  Rejected
  -------------------------------------------------------------
  dept1       2       1             0
  dept2       1       0             0
  dept3       1       1             1
  -------------------------------------------------------------
  </code></pre>
  
  <p>I am not able to write the mysql query for this. Any help is highly appreciable.</p>