作者: roych 时间: 2011-6-8 01:26
SELECT Format([Sheet2]![生产日期],"YYYY-MM") AS 生产日期, Sum(Sheet2.生产数量) AS 生产数量之总计, Count(Sheet2.生产日期) AS 生产日期之计数
FROM Sheet2
GROUP BY Format([Sheet2]![生产日期],"YYYY-MM");
把Sheet2改成你的表名称。作者: danis 时间: 2011-6-8 21:51
SELECT Format(t.生产日期,'yyyy-mm') AS 年月, Sum(t.生产数量) AS 生产总计, t1.生产计数
FROM a AS t INNER JOIN [SELECT Format(生产日期,"yyyy/mm") AS 年月, Count(*) AS 生产计数 FROM (SELECT DISTINCT 生产日期 FROM A) AS T GROUP BY Format(生产日期,"yyyy/mm")]. AS t1 ON Format(t.生产日期,'yyyy-mm')=t1.年月
GROUP BY Format(t.生产日期,'yyyy-mm'), t1.生产计数; 作者: roych 时间: 2011-6-9 01:54
太复杂了……完全没必要用上内联接。按年月分组后,其它都可以汇总了~~作者: danis 时间: 2011-6-14 20:26
版主来个例子作者: caoguangyao 时间: 2011-6-14 21:07
SELECT Format([日期],"yyyy/mm") AS 年月, Sum(表2.生产数量) AS 生产数量之合计, Count([日期]) AS 统计天数
FROM 表2
GROUP BY Format([日期],"yyyy/mm");