oracle查询group by视图报错
select t.yydm, t.yydj, t.jsny, t.xzlbzh xzlb/*, (select item_name from tb_dic_fyshjs_bblb where item_id = t.xzlbzh and valid_flag = '1') xzlbmc*/ from (select YYDM, (select yljgmc from tb_dic_ddyljg where yljgdm = yydm) yymc, (select yljglbmc from yboltp.TB_DIC_DDYLJG_YLJGLB@oltpsync where yljglb = trim(pk_common_fyshjs.func_GetDDJGZB(a.yydm, '0009')) and yljgzlb = trim(pk_common_fyshjs.func_GetDDJGZB(a.yydm, '0010'))) yydj, JSNY, decode(xzlb, '1', '01', '2', '01', '6', '01', '3', '02', '4', '03', '5', '03', '7', '04', '8', '04', xzlb) xzlbzh from tb_fyshjs_zyyp a where 1 = 1 group by yydm, decode(xzlb, '1', '01', '2', '01', '6', '01', '3', '02', '4', '03', '5', '03', '7', '04', '8', '04', xzlb), jsny) t
查询注释部分
/*, (select item_name from tb_dic_fyshjs_bblb where item_id = t.xzlbzh and valid_flag = '1') xzlbmc*/
就会报错,显示不是分组函数。但是查询视图的xzlbzh字段是不会报错的,当把它作为子查询的条件时才会报错,且视图查询完全没问题,困扰了很久,至今不知道原因。

浙公网安备 33010602011771号