目前我有这样的一条SQL语句,使用动态传参的方式,SQL语句是这样的:
select
“type”,
case
when type = ‘1’ then ‘电表’
when type = ‘2’ then ‘水表’
when type = ‘3’ then ‘气表’
when type = ‘4’ then ‘油表’
end as dtype,
to_char(createtime, ‘yyyy-MM-dd’) as createtime,
sum(used) used
from t_device_info
where (to_char(createtime, ‘yyyy-MM-dd’) = ‘${createtime}’ OR to_char(createtime, ‘yyyy-MM-dd’) = to_char(now()::timestamp, ‘yyyy-MM-dd’))
GROUP BY “type”,to_char(createtime, ‘yyyy-MM-dd’)
ORDER BY to_char(createtime, ‘yyyy-MM-dd’),“type”;
目前遇到的问题是:
使用跳转链接,进行跳转页面后,查询出的数据只有to_char(createtime, ‘yyyy-MM-dd’) = ‘${createtime}’ 这个条件的数据,OR 语句后的条件数据没有查询出来。