有这样一个表:rshu我需要查询出这样的意思,但这个肯定是不对的
select sum(count('进厂日期今年的第几周')-count('离职日期今年的第几周'))
from rshu where '进厂日期今年的第几周'=19 and '离职日期今年的第几周'=19服务器: 消息 130,级别 15,状态 1,行 1
不能对包含聚合或子查询的表达式执行聚合函数。
请大侠指点一下 ,主要是sum 和 group by 虽然晓得这个问题很低级。
select sum(count('进厂日期今年的第几周')-count('离职日期今年的第几周'))
from rshu where '进厂日期今年的第几周'=19 and '离职日期今年的第几周'=19服务器: 消息 130,级别 15,状态 1,行 1
不能对包含聚合或子查询的表达式执行聚合函数。
请大侠指点一下 ,主要是sum 和 group by 虽然晓得这个问题很低级。
from rshu
where '进厂日期今年的第几周'=19 and '离职日期今年的第几周'=19
group by employeeid
from rshu where '进厂日期今年的第几周'=19 and '离职日期今年的第几周'=19
from rshu where '进厂日期今年的第几周'=19 and '离职日期今年的第几周'=19
不知道楼主想做什么,如果where条件是and,那么按楼主的想法这个聚合根本没必要做的,结果都是0
直接减不就可以了 何必还SUM?
from rshu where '进厂日期今年的第几周'=19 and '离职日期今年的第几周'=19
目的
计算出每一周的实际人数,也就是本周以及之前进场人数(count('进厂日期今年的第几周'))减去
本周离职人数(count('离职日期今年的第几周') where '离职日期今年的第几周'='进厂日期今年的第几周')
谢谢 ~~