### Cause: java.sql.SQLSyntaxErrorException: ORA-00979: 不是 GROUP BY 表达式
;
bad SQL grammar [];
nested exception is java.sql.SQLSyntaxErrorException: ORA-00979: 不是 GROUP BY 表达式
【mybatis使用函数 再group by 传参报错】错误配置:
SELECT fun_TimeDimension(SEND_TIME,#{grant} ) AS SEND_TIME,sum(total) as total FROM T_TRAFFICPARAMMSG
WHERE
TO_DATE (
SEND_TIME,
'yyyy-mm-dd hh24:mi:ss'
) >
= TO_DATE (
#{startTime},
'yyyy-mm-dd hh24:mi:ss'
)
AND TO_DATE (
SEND_TIME,
'yyyy-mm-dd hh24:mi:ss'
) <
= TO_DATE (
#{endTime},
'yyyy-mm-dd hh24:mi:ss'
)
and DIRECTION = #{director}
group by fun_TimeDimension(SEND_TIME,#{grant} )
ORDER BY SEND_TIME asc
--------------正确配置
SELECT fun_TimeDimension(SEND_TIME,${grant} ) AS SEND_TIME,sum(total) as total FROM T_TRAFFICPARAMMSG
WHERE
TO_DATE (
SEND_TIME,
'yyyy-mm-dd hh24:mi:ss'
) >
= TO_DATE (
#{startTime},
'yyyy-mm-dd hh24:mi:ss'
)
AND TO_DATE (
SEND_TIME,
'yyyy-mm-dd hh24:mi:ss'
) <
= TO_DATE (
#{endTime},
'yyyy-mm-dd hh24:mi:ss'
)
and DIRECTION = #{director}
group by fun_TimeDimension(SEND_TIME,${grant} )
ORDER BY SEND_TIME asc
把#{grant} 改成 ${grant}
推荐阅读
- 框架|Mybatis的一级缓存和二级缓存
- Mybatis日志工厂
- MyBatis的功能架构是怎样的
- Mybatis入门之CRUD
- mybatis之缓存机制
- Mybatis练习(1)
- Java|MyBatis(五)——MyBatis中的缓存机制
- mybatis之脚本解析器
- mybatis|记mybatis查询null字段导致的NPE
- Mybatis 动态查询、插入、修改操作