错误如下:我取1月却出现了1月和2月
错误SQL:
代码为
select 月份, sum(金额) as 金额
FROM
(select SUBSTRING(riqi, 6,2) as 月份, sum(amountprice)as 金额
from testxiaoshoufahuo
where ju=‘南方局’
GROUP BY SUBSTRING(riqi, 6,2)
UNION
select SUBSTRING(riqi, 6,2) as 月份,-SUM(amount) as 金额
from xiaoshoutuihuomingxi
where ju =‘南方局’
GROUP BY SUBSTRING(riqi, 6,2)
)a
GROUP BY 月份
${if(len(yue)==0,"",“and 月份 = '” + yue + “’”)}
修改如下:
select 月份, sum(金额) as 金额
FROM
(select SUBSTRING(riqi, 6,2) as 月份, sum(amountprice)as 金额
from testxiaoshoufahuo
where ju=‘南方局’
GROUP BY SUBSTRING(riqi, 6,2)
UNION
select SUBS
帆软SQL添加参数出错
最新推荐文章于 2024-05-29 16:27:23 发布
在尝试使用帆软报表时,遇到一个SQL错误,原因为取1月数据时出现了1月和2月的数据。错误SQL中,条件部分在参数为空时产生了语法错误。通过在WHERE子句中加入`1=1`来确保SQL语句始终有效,解决了问题。修复后的SQL在参数正确时能按预期运行。
摘要由CSDN通过智能技术生成