SELECT IIf([月份]<=3,"1季度",IIf([月份]<=6,"2季度",IIf([月份]<=9,"3季度","4季度"))) AS 季度, 表1.商品, Sum(表1.库存) AS 库存总计, Sum(表1.销售) AS 销售总计
FROM 表1
GROUP BY IIf([月份]<=3,"1季度",IIf([月份]<=6,"2季度",IIf([月份]<=9,"3季度","4季度"))), 表1.商品;
[attach]42903[/attach]作者: xxh6391 时间: 2010-7-30 19:57 回复 todaynew 的帖子
有道理,库存在分组查询中应该选最后一个记录。
SELECT IIf([月份]<=3,"1季度",IIf([月份]<=6,"2季度",IIf([月份]<=9,"3季度","4季度"))) AS 季度, 表1.商品, Last(表1.库存) AS 期末库存, Sum(表1.销售) AS 销售总计
FROM 表1
GROUP BY IIf([月份]<=3,"1季度",IIf([月份]<=6,"2季度",IIf([月份]<=9,"3季度","4季度"))), 表1.商品 作者: xxh6391 时间: 2010-7-30 22:16 回复 todaynew 的帖子