目的是汇总:本周上周总累计的数据。最终预计的效果数据库查询,限制了日期范围,最后返回的是单个一行的数据 where day between '${start}' and '${end}'参数设置start:SWITCH(A4,
"本周",DATEINWEEK(TODAY(),1),
"上周",DATEINWEEK(TODAY(),1)-7,
"累计","2014-06-08")end:SWITCH(A4,
"本周",TODAY()-1,
"上周",DATEINWEEK(TODAY(),1)-1,
"累计",TODAY()-1)但是 返回值一直有误。目的也就是,每行的返回值是不同参数值,控制的结果----自己的解决办法在 sql 中 用 增加类型列 和 union 组合各个查询的值select '本周' as type ...
...
where day between '${start_now}' and '${end_now}'
union
select '上周' as type ...
...
where day between '${start_pre}' and '${end_pre}'