nested exception is com.gbase.jdbc.exceptions.jdbc4.GBaseSyntaxErrorException: Mixing of GROUP colum

时间:2021-02-28 22:51:28

求MIN(),MAX(),COUNT(),…这几种函数时,需要根据某一个指标进行分组,需要在sql的最后加上 group by **…
异常源码:

 org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select region_code as nname, sum(CUSTOMER_NUM) as m from heyue_quanjiang where length(region_code) = ? and ddate = ? and CONTRACT_TYPE = ?]; nested exception is com.gbase.jdbc.exceptions.jdbc4.GBaseSyntaxErrorException: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
    at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:95)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:639)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:668)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:676)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:716)
    at com.data.dao.BasicDataCalculationDao.getRatioTypeHeYueDescByKPI_SUM(BasicDataCalculationDao.java:1391)