用ASP如何实现数据对比功能?
本帖最后由 yrdfl 于 2013-07-23 17:46:08 编辑
假设我设计了一个商品销售系统,我的要求是:
汇总查询某一时段各项商品的销售量,同时查询出
对应商品上年同一时段 的销售量,进行对比。(ACCESS数据库)
请问用ASP如何实现这个数据对比功能,请老师们不吝赐教,给出代码,不甚感谢!
------解决方案-------------------- 引用: sql2="select name ,sum(amount) as b from shuju where date between "...." group by name"
sql3="select name ,sum(amount) as b from shuju where date between "...." group by xxxx "
请问,sql3的group by xxxx 如何定义,才能与sql2的group by name相对应?
SELECT sum(iif(sj between #2012-7-1# and #2012-7-20#,num,0)) AS qnum, sum(iif(sj between #2013-7-1# and #2013-7-20#,num,0)) AS jnum, name AS dname
FROM a
GROUP BY name;
针对access数据库写的,只要一个sql搞定的,表价格如下:
查询2013-7-1至2013-7-20 num的总和以及去年同一时间的总和,结果如图: