mysqlcount
select d.department,
count(case e.sex when e.sex='f' and p.position !='主管' then p.id end) fq,
count(case e.sex when e.sex='f' and p.position ='主管' then p.id end) fz,
count(case e.sex when e.sex='m' and p.position !='主管' then p.id end) mq,
count(case e.sex when e.sex='m' and p.position ='主管' 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;
出现后面两个count统计不出来是什么原因?
为什么下面个可以查出来?
SELECT d.department,
COUNT(CASE WHEN e.sex='f' AND p.position !='主管' THEN p.id END) fq,
COUNT(CASE WHEN e.sex='f' AND p.position ='主管' THEN p.id END) fz,
COUNT(CASE WHEN e.sex='m' THEN CASE WHEN p.position !='主管' THEN p.id END END) mq
COUNT(CASE WHEN e.sex='m' THEN CASE WHEN p.position ='主管' THEN p.id END 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
图书《网页制作与PHP语言应用》,由武汉大学出版社于2006出版,该书为普通高等院校网络传播系列教材之一,主要阐述了网页制作的基础知识与实践,以及PHP语言在网络传播中的应用。该书内容涉及:HTML基础知识、PHP的基本语法、PHP程序中的常用函数、数据库软件MySQL的基本操作、网页加密和身份验证、动态生成图像、MySQL与多媒体素材库的建设等。
447
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号