表A,有时间字段1,数值字段2,当时间过滤组件小于某个具体日期时,查询出来的是历史无用的值,需要显示为空。
select 时间字段1,数值字段2
from 表A
where 1=1
${if(len(date)=0,""," and cast(具体日期 as timestamp) <=cast('"+date+"' as timestamp) ")}
直接在where子句中做比较,这些记录无法显示。时间过滤组件绑定的数据集参数date无法直接在select里面使用。
要怎么写SQL呢。
${if(date<"2025-01-01","1=2"," and cast(具体日期 as timestamp) <=cast('"+date+"' as timestamp) ")}
-------------------------------------
参数名最好换一下,不要用date ,用p_date之类的