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
  • 50,732
  • 33
  • 89
  • 96
Akshay Raje
  • 852
  • 9
  • 20
  • 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
  • 852
  • 9
  • 20
AdrianBR
  • 2,762
  • 1
  • 15
  • 29