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?

4

1 回答 1

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`
于 2013-09-26T10:39:00.040 回答