|
如果不明白,也可以用四步查询的方法:
1、新建查询:
SELECT tbl卸货派工.主班 AS 班级, tbl卸货派工.日期, IIf(Len(Trim(nz([副班],"")))=0,1,0.5) AS 卸车数, IIf(Len(Trim(nz([副班],"")))=0,[实到数],[实到数]/2) AS 卸货箱数, IIf([分货]=True,IIf(Len(Trim(nz([副班],"")))=0,1,0.5),0) AS 分货次数, IIf([分货]=True,IIf(Len(Trim(nz([副班],"")))=0,[实到数],[实到数]/2),0) AS 分货箱数, tbl卸货派工.卸车ID
FROM tbl卸货派工
保存为“查询1”
2、新建查询:
SELECT tbl卸货派工.副班 AS 班级, tbl卸货派工.日期, IIf(Len(Trim(nz([主班],"")))=0,1,0.5) AS 卸车数, IIf(Len(Trim(nz([主班],"")))=0,[实到数],[实到数]/2) AS 卸货箱数, IIf([分货]=True,IIf(Len(Trim(nz([主班],"")))=0,1,0.5),0) AS 分货次数, IIf([分货]=True,IIf(Len(Trim(nz([主班],"")))=0,[实到数],[实到数]/2),0) AS 分货箱数, tbl卸货派工.卸车ID
FROM tbl卸货派工
WHERE (((Len(Trim(nz([副班],""))))<>0))
保存为“查询2”
3、新建查询:
SELECT * FROM 查询1 UNION SELECT * FROM 查询2
保存为“查询3”
4、新建查询:
SELECT 查询3.班级, 查询3.日期, Sum(查询3.卸车数) AS 卸车数之总计, Sum(查询3.卸货箱数) AS 卸货箱数之总计, Sum(查询3.分货次数) AS 分货次数之总计, Sum(查询3.分货箱数) AS 分货箱数之总计
FROM 查询3
GROUP BY 查询3.班级, 查询3.日期
ORDER BY 查询3.日期;
保存为“查询4”
运行“查询4”,OK!
|
|