title: How to create a new column from the data received using sum(1) on that row in mysql
body: <p>I have a query where I m getting the count of that row but I m trying to receive count based on two conditions but the output that I get is in one single row for both the conditions.I want to get another new Column for the second condition similar to how I get for my first condition.My Query is below</p>
  
  <pre><code>SELECT 
      SUM(1) AS Usercount, feild
  FROM
      (SELECT 
          *
      FROM
          (SELECT 
          id,
              GROUP_CONCAT(DISTINCT code) AS feild
      FROM
          table
      WHERE
          type = 'Usercount' and code = 001
              AND locId IN (SELECT 
                  id
              FROM
                  location
              WHERE
                  id IN (1) AND status = 1)
      GROUP BY id) AS deptdata
      WHERE
          feild NOT LIKE '%,%') AS Data
  GROUP BY feild 
  UNION SELECT 
      SUM(1) AS EmployeeCount, feild
  FROM
      (SELECT 
          *
      FROM
          (SELECT 
          id,
              GROUP_CONCAT(DISTINCT code) AS feild
      FROM
          table
      WHERE
          type = 'EmployeeCount' and code = 001
              AND locId IN (SELECT 
                  id
              FROM
                  location
              WHERE
                  id IN (1) AND status = 1)
      GROUP BY id) AS deptdata
      WHERE
          feild NOT LIKE '%,%') AS Data
  GROUP BY feild 
  
  </code></pre>
  
  <p>After excecuting this I get two columns first column is for UserCount and second column is for code .That is </p>
  
  <pre><code>Usercount Code
  3         001
  </code></pre>
  
  <p>But I want the Output as </p>
  
  <pre><code>UserCount EmployeeCount  Code
  3              2          001
  
  </code></pre>