SELECTd. department, COUNT (CASEe. sexWHENe. sex & #39; f & #39; ANDp. position! & #39; supervisor & #39; THENp. idEND) fq, COUNT (CASEe. sexWHENe. sex & #39; f & #39; ANDp. position & #39; supervisor & #39; THENp. idEND) fz, COUNT (CASEe. sexWHENe. sex & #39; m & #39; ANDp. positi mysqlcount
SELECT d. department,
COUNT (CASE e. sex WHEN e. sex = 'f' AND p. position! = 'Supervisor 'THEN p. id END) fq,
COUNT (CASE e. sex WHEN e. sex = 'f' AND p. position = 'supervisor 'THEN p. id END) fz,
COUNT (CASE e. sex WHEN e. sex = 'm' AND p. position! = 'Supervisor 'Then p. id END) mq,
COUNT (CASE e. sex WHEN e. sex = 'm' AND p. position = 'supervisor 'THEN p. id END) mz,
COUNT (e. id) xj
FROM department d left join employ e ON d. id = e. deptid
Left join position p ON e. positionid = p. id
Group by d. id;
Why does the following two count statistics fail?
Why can we find the following?
SELECT d. department,
COUNT (case when e. sex = 'f' AND p. position! = 'Supervisor 'THEN p. id END) fq,
COUNT (case when e. sex = 'f' AND p. position = 'supervisor 'THEN p. id END) fz,
COUNT (case when e. sex = 'm' then case when p. position! = 'Supervisor 'THEN p. id END) mq
COUNT (case when e. sex = 'm' then case when p. position = 'supervisor 'Then p. id END) mz,
COUNT (e. id) xj
FROM department d left join employ e ON d. id = e. deptid
Left join position p ON e. positionid = p. id
Group by d. id