0

Here's a simplified snapshot of my data on sqlfiddle. Its basically a 3 column table with employee emails (emp_email), departments (emp_dept) and some text data (emp_assessment_data). The query for department names and headcount is simple:

SELECT `emp_dept`,COUNT(*) AS 'DEPT_COUNT' FROM `employee_master` GROUP BY `emp_dept`

How to I write a query to add one more column which has a count of only blank emp_assessment_data?

fancyPants
  • 49,071
  • 32
  • 84
  • 94
Akshay Raje
  • 842
  • 9
  • 19
  • possible duplicate of [MYSQL - Rows to Columns](http://stackoverflow.com/questions/1241178/mysql-rows-to-columns) – Alma Do Sep 26 '13 at 10:04

1 Answers1

0
SELECT `emp_dept`, 
COUNT(*) AS 'DEPT_COUNT', 
SUM(IF(`emp_assessment_data` = '', 1, 0)) as 'BLANK_EMP_ASSESSMENT_COUNT' 
FROM `employee_master` GROUP BY `emp_dept`
Akshay Raje
  • 842
  • 9
  • 19
AdrianBR
  • 2,695
  • 1
  • 13
  • 27