mybatis使用函式 再group by 傳參報錯
### Cause: java.sql.SQLSyntaxErrorException: ORA-00979: 不是 GROUP BY 表示式
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00979: 不是 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}