DatabaseError: Execution failed on sql 'select JHETPCODE,JHETPNAME,sum(HXTOTAL) "销售",sum(hmtotal) "毛利",sum(XsCount) "数量" from tSalPluDetail202301 A where exists(select 1 from torgexinfo where (udp1='0-超市组织'or udp1='超市') and orgcode=A.OrgCode) and JHETPNAME like %好利% and rptdate between '2023-01-01' and '2023-05-31' and datatype<>'5' group by JHETPCODE,JHETPNAME': ORA-00911: 无效字符 优化
时间: 2024-01-01 17:07:04 浏览: 70
IntelliJ IDEA报错Error:java: Compilation failed: internal java compiler error的解决办法
这条 SQL 查询语句中的错误是因为 `JHETPNAME like %好利%` 中的 `%` 前后没有加引号,导致语法错误。正确的写法应该是 `JHETPNAME like '%好利%'`。另外,如果查询的数据量比较大,可以考虑添加索引来优化查询速度。例如,在 `tSalPluDetail202301` 表的 `JHETPNAME` 字段上添加一个索引,可以加快查询速度。修改后的 SQL 查询语句如下:
```
select JHETPCODE,JHETPNAME,sum(HXTOTAL) "销售",sum(hmtotal) "毛利",sum(XsCount) "数量"
from tSalPluDetail202301 A
where exists(select 1 from torgexinfo where (udp1='0-超市组织'or udp1='超市') and orgcode=A.OrgCode)
and JHETPNAME like '%好利%'
and rptdate between '2023-01-01' and '2023-05-31'
and datatype<>'5'
group by JHETPCODE,JHETPNAME;
```
阅读全文