你看看增加一列行不行,代码如下: select N_community,C_stat_time,sum(N_up) as N_up,substr(N_community,1,level*2) as Column1, from T_retire_change_collect where N_state=1 group by Column1,C_stat_time order by C_stat_time desc,Column1
group by 函数就是这样的。 比如对于aaa.aab,aac。前两个字符都是aa,如果你按aa分组,却又要显示,那是显示aaa,aab还是aac呢?
为什么一定要把substr放在group by中呢?这样不行啊
为什么不行呢? 不是我要放啊,分组就是按SUBSTR后的结果分的啊
select max(N_community),C_stat_time,sum(N_up) as N_up from T_retire_change_collect where N_state=1 group by substr(N_community,1,level*2),C_stat_time order by C_stat_time desc,N_community这样试试
执行不了,ORA-00923:FROM keyword not fount where expected楼上的是MM?
select N_community,C_stat_time,sum(N_up) as N_up,substr(N_community,1,level*2) as Column1,
from T_retire_change_collect where N_state=1
group by Column1,C_stat_time
order by C_stat_time desc,Column1
比如对于aaa.aab,aac。前两个字符都是aa,如果你按aa分组,却又要显示,那是显示aaa,aab还是aac呢?
不是我要放啊,分组就是按SUBSTR后的结果分的啊
from T_retire_change_collect where N_state=1
group by substr(N_community,1,level*2),C_stat_time
order by C_stat_time desc,N_community这样试试