不知道小伙伴们是否有在sql 中使用过 以下类似代码:
select case when xxx='1' then t1.name
when xxx='2' then t1.address end as groupCol,
sum(t1.xxx) as x,sum(t1.xx) as xx
* from stuent t1
group by case when xxx='1' then t1.name
when xxx='2' then t1.address end
上面这段代码呢, 是根据不同的条件进行的分组统计 . 在之前一个项目使用的是公司的一套框架,没有使用myBatis 框架. 执行起来也OK .完全满足条件.
奇怪的事情就发生在昨天. 在myBatis 中同样的用法. 控制台打印的SQL. 在PLSQL 中执行没有问题. 但是在代码中运行报 字段不是分组函数. 让我很是震惊 .由于时间没有深入去了解具体是什么原因.
后面就使用了另外一种方式来进行替换.
select
jg.dsswjgmc as swjgmc,
jg.qxswjgmc as swjgmc,
count(jb.XMBH) as XMSL
from table jg
jg.dsswjgmc
jg.qxswjgmc
以上就是此次遇到的问题 .希望能帮到大家. 也希望有明白原因的可以给我评论留言,



